Date: Wed, 29 Sep 1999 17:03:56 +0200 From: Wolfram Schneider <wosch@cs.tu-berlin.de> To: questions@freebsd.org Subject: [bytong@yahoo.com: (no subject)] Message-ID: <19990929170355.A3481@freno.cs.tu-berlin.de>
next in thread | raw e-mail | index | archive | help
----- Forwarded message from bytong <bytong@yahoo.com> -----
Date: Wed, 29 Sep 1999 22:20:02 +0800
From: bytong <bytong@yahoo.com>
Reply-To: bytong@yahoo.com
To: wosch@FreeBSD.org
Subject: (no subject)
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?
The parent process is just a child process "forked" by another
process,on the result of above
example,i think,getppid() should always return 1.
My freebsd is freebsd 2.2.8
Please tell me why?
My email address: bytong@yahoo.com
Thanks and best regards!
----- End forwarded message -----
--
Wolfram Schneider <wosch@freebsd.org> http://wolfram.schneider.org
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?19990929170355.A3481>
