lkml.org 
[lkml]   [2000]   [Mar]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectCLONE_PDEATHKILL introduction
Hi

I would like to propose CLONE_PDEATHKILL option.
This option just fills the gap that exists when the thread
is started and before the prctl can be called to instruct
the child to receive signal when parent dies. So with this
option the clone/prctl combination would be complete.

The patch is very simple and uses the logic already
introduced by prctl:

--- kernel/fork.c.bak Fri Mar 10 14:47:58 2000
+++ kernel/fork.c Fri Mar 10 14:58:20 2000
@@ -705,7 +705,10 @@
/* ok, now we should be set up.. */
p->swappable = 1;
p->exit_signal = clone_flags & CSIGNAL;
- p->pdeath_signal = 0;
+ if (clone_flags & CLONE_PDEATHKILL)
+ p->pdeath_signal = SIGKILL;
+ else
+ p->pdeath_signal = 0;

/*
* "share" dynamic priority between parent and child, thus the
--- include/linux/sched.h.bak Fri Mar 10 14:48:05 2000
+++ include/linux/sched.h Fri Mar 10 14:58:21 2000
@@ -36,6 +36,7 @@
#define CLONE_PTRACE 0x00002000 /* set if we want to let tracing
continue on the child too */
#define CLONE_VFORK 0x00004000 /* set if the parent wants the
child to wake it up on mm_release */
#define CLONE_PARENT 0x00008000 /* set if we want to have the
same parent as the cloner */
+#define CLONE_PDEATHKILL 0x00010000 /* set if we want that child
will receive SIGKILL after parent dies */

/*
* These are the constant used to fake the fixed-point load-average

Any comments are highly appreciated
regards
Pavel




This small program illustrates the problem of prctl as someone mentioned
earlier
- the prctl call could come too late (parent is already pid=1). The
CLONE_PDEATHKILL
option would solve this gap.

char stack2[10000];
int f2(void *arg)
{
prctl(PR_SET_PDEATHSIG, SIGKILL);
while (1) {
printf("f2 pid=%d, ppid=%d\n", getpid(), getppid());
sleep(1);
}
return 0;
}
int main()
{
printf("main pid=%d, ppid=%d\n", getpid(), getppid());
clone(f2, stack2 + sizeof(stack2), CLONE_VM | CLONE_FS |
CLONE_FILES, NULL);
_exit(0);
return 0;
}



-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:56    [W:0.064 / U:2.480 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site