Date: Sat, 20 Mar 1999 15:28:00 +0530 From: Samit Pal <samit@usa.ltindia.com> To: FreeBSD-Questions@FreeBSD.ORG Subject: rfork() Message-ID: <36F37127.7C0B121D@usa.ltindia.com>
next in thread | raw e-mail | index | archive | help
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. Code: #include <unistd.h> 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); } } Output: $ cc test.c $ a.out & $ Parent Process start Parent process continues with childId(10759) Samit,PID(10758) ps PID TT STAT TIME COMMAND 10697 p2 Ss 0:00.07 -sh (sh) 10758 p2 S 0:00.00 a.out 10759 p2 Z 0:00.00 (a.out) 10760 p2 R+ 0:00.00 ps why it is created zombie and it does not execute the code ? --Samit. 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?36F37127.7C0B121D>