Date: Wed, 29 Sep 1999 11:42:43 -0500 From: Dan Nelson <dnelson@emsphone.com> To: bytong <bytong@yahoo.com> Cc: questions@FreeBSD.ORG Subject: Re: [bytong@yahoo.com: (no subject)] Message-ID: <19990929114243.A71962@dan.emsphone.com> In-Reply-To: <19990929170355.A3481@freno.cs.tu-berlin.de> References: <19990929170355.A3481@freno.cs.tu-berlin.de>
next in thread | previous in thread | raw e-mail | index | archive | help
From bytong <bytong@yahoo.com>:
> Dear :
> please find the following c program
> main()
> {
> int i;
> while ((i=fork())==-1);
> if (i)
> printf("It's parent process,process id %d parent id %d\n",getpid(),getppid());
> else
> printf("It's child process,process id %d parent id %d\n",getpid(),getppid());
> }
>
> It's very simple ,but the result amaze me. The parent process
> return 246,181 which express the process id and its parent process
> id,the problem is child process which return 247,1, child process id
> is 247, but its parent's process id is 1 not 246, why?
Probably because the parent exited before the child got to the
getppid() call. Children whose parents have died are 'owned' by init
(pid 1).
--
Dan Nelson
dnelson@emsphone.com
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19990929114243.A71962>
