From: Davy Durham <pubaddr2@davyandbeth.com>
To: Jeff.Fellin@rflelect.com
Cc: linux-kernel@vger.kernel.org
Subject: Re: disowning a process
Date: Fri, 27 May 2005 13:15:01 -0500 [thread overview]
Message-ID: <429763A5.1080905@davyandbeth.com> (raw)
In-Reply-To: <OFA0F07206.30BD7843-ON8525700E.00611011@teal.com>
Thanks for the reply!
Well this seems straight-forward enough, but it doesn't seem to work for
me.. see if I have everything straight..
#include <unistd.h>
#include <stdio.h>
int main()
{
if(fork())
{ /* parent */
sleep(15);
}
else
{ /* child */
printf("setpgrp returned: %d\n",setpgrp());
sleep(5);
}
}
I run the program.. setpgrp is returning zero.. then I quickly look at
the ps listing.. the child's pid is still the parent's, but that may be
okay.. Then after 5 seconds when the child exits.. I do the ps again
and I do still see that the child is now defunct.. the desired effect is
that the child would go away because I don't care what the exit status
was. I was thinking that if init could become the parent of the newly
forked child, then it would clean it up when it exits.
Any ideas?
-- Davy
Jeff.Fellin@rflelect.com wrote:
>Davy,
>After you fork the process, use setpgrp() to make the process the head of
>it's own process group.
>check man -S2 setpgrp for details.
>
>
>
>Hi, I'm not sure if there's a posix way of doing this, but wanted to
>check if there is a way in linux.
>
>I want to have a daemon that fork/execs a new process, but don't want
>(for various reasons) the responsibility for cleaning up those process
>with the wait() function family. I'm assuming that if the init process
>became the parent of one of these forked processes, then it would clean
>them up for me (is this assumption true?). Besides the daemon process
>exiting, is there a way to disown the process on purpose so that init
>inherits it?
>
>Thanks,
> 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/
>
>
>
>
next parent reply other threads:[~2005-05-27 18:18 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <OFA0F07206.30BD7843-ON8525700E.00611011@teal.com>
2005-05-27 18:15 ` Davy Durham [this message]
2005-05-27 17:30 disowning a process Davy Durham
2005-05-27 18:04 ` Steven Rostedt
2005-05-27 18:55 ` Davy Durham
2005-05-27 19:05 ` Davy Durham
2005-05-27 19:27 ` Steven Rostedt
2005-05-27 19:07 ` Steven Rostedt
2005-05-27 20:57 ` Alan Cox
2005-05-27 23:34 ` Davy Durham
2005-05-28 1:38 ` Steven Rostedt
2005-05-28 1:48 ` Steven Rostedt
2005-05-28 23:18 ` Davy Durham
2005-05-27 18:54 ` J. Scott Kasten
2005-05-27 19:38 ` Steven Rostedt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=429763A5.1080905@davyandbeth.com \
--to=pubaddr2@davyandbeth.com \
--cc=Jeff.Fellin@rflelect.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox