lkml.org 
[lkml]   [2005]   [May]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: disowning a process
Alan Cox wrote:

>On Gwe, 2005-05-27 at 19:55, Davy Durham wrote:
>
>
>>Cool.. I looked at the daemon function and I might be able to use it..
>>
>>
>
>Using daemon() is generally wise - it is basically a double fork and
>then one exits so that the orphan child becomes owned by init. However
>it also knows about platform specific considerations like setpgrp v
>setsid, whether an ioctl must be done to disown the controlling tty etc
>which can be fairly OS generation specific.
>
>

Well, when I tried using it in a program with some sleeps to test.. I
noticed that the intermediate process that daemon creates is not cleaned
up with a wait() call (so I see a defunct process in the ps listing).

If I manually do the double fork() then I can call waitpid() myself for
the pid that I know it spawned. But if I just call wait() after
calling daemon, then I don't know if I just cleaned up the pid it
spawned (do I?), or some other previously spawned one (for perhaps
totally different reasons)..

For my specifics it may not be a problem, but I guess I'm just whining
about the fact that daemon() doesn't clean it up itself (or can it?)

Thanks much,
Davy

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

\
 
 \ /
  Last update: 2005-05-28 01:45    [W:0.068 / U:0.136 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site