From owner-freebsd-questions Fri Mar 26 22:40:37 1999 Delivered-To: freebsd-questions@freebsd.org Received: from alpha.comkey.com.au (alpha.comkey.com.au [203.9.152.215]) by hub.freebsd.org (Postfix) with SMTP id 8259E14E43 for ; Fri, 26 Mar 1999 22:40:31 -0800 (PST) (envelope-from gjb@comkey.com.au) Received: (qmail 8081 invoked by uid 1001); 27 Mar 1999 06:11:59 -0000 Message-ID: <19990327061159.8080.qmail@alpha.comkey.com.au> X-Posted-By: GBA-Post 1.04 06-Feb-1999 X-PGP-Fingerprint: 5A91 6942 8CEA 9DAB B95B C249 1CE1 493B 2B5A CE30 Date: Sat, 27 Mar 1999 16:11:59 +1000 From: Greg Black To: samit@usa.ltindia.com Cc: FreeBSD-Questions@FreeBSD.ORG Subject: Re: rfork() References: <36F37127.7C0B121D@usa.ltindia.com> In-reply-to: <36F37127.7C0B121D@usa.ltindia.com> of Sat, 20 Mar 1999 15:28:00 +0530 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > Can any one suggest how to use rfork( RFPROC | RFMEM ); > according to the manual, freeBSD supports this and it should create a > new process which will share the address space. > But what I'm getting is > a) It returns only to the parent process with a childID. > b) It doesn't go into child part > c) 'PS' shows that a child process is active. > > #include > main() > { > int childId; > printf("Parent Process start \n"); > if ( (childId = rfork(RFMEM | RFPROC) ) == 0 ) { > printf("In Child childId(%d) PId(%d)\n", > childId,getpid() ); > sleep(4); > exit(0); > } > { > char buf[10] = "Samit"; > int nRet; > printf("Parent process continues with childId(%d) > %s,PID(%d)\n", > childId, buf,getpid()); > sleep(5); > } > } I just compiled this code on a 2.2.8-release system and both processes produced the expected output. What version of FreeBSD were you using? -- Greg Black To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message