Hello,
This was posted to freebsd-questions with no reply.
I tried this and the child process created a core file.
I also tried the other options and they seem to work.
Just RFPROC and RFMEM DON'T!
Thanks,
Michael Mercer
--------------------
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 [email protected]
with "unsubscribe freebsd-questions" in the body of the message
To Unsubscribe: send mail to [email protected]
with "unsubscribe freebsd-current" in the body of the message