From owner-freebsd-questions Wed Sep 29 9:43: 5 1999 Delivered-To: freebsd-questions@freebsd.org Received: from dan.emsphone.com (dan.emsphone.com [199.67.51.101]) by hub.freebsd.org (Postfix) with ESMTP id A0132156B7 for ; Wed, 29 Sep 1999 09:42:49 -0700 (PDT) (envelope-from dan@dan.emsphone.com) Received: (from dan@localhost) by dan.emsphone.com (8.9.3/8.9.3) id LAA72452; Wed, 29 Sep 1999 11:42:43 -0500 (CDT) (envelope-from dan) Date: Wed, 29 Sep 1999 11:42:43 -0500 From: Dan Nelson To: bytong Cc: questions@FreeBSD.ORG Subject: Re: [bytong@yahoo.com: (no subject)] Message-ID: <19990929114243.A71962@dan.emsphone.com> References: <19990929170355.A3481@freno.cs.tu-berlin.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0pre2i In-Reply-To: <19990929170355.A3481@freno.cs.tu-berlin.de> X-OS: FreeBSD 4.0-CURRENT Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG From bytong : > 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