Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 20 Mar 1999 23:07:27 -0500
From:      "Michael E. Mercer" <mmercer@ipass.net>
To:        freebsd-current@freebsd.org
Cc:        freebsd-hackers@freebsd.org
Subject:   rfork()
Message-ID:  <36F4707E.E7A6D897@ipass.net>

next in thread | raw e-mail | index | archive | help
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 majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?36F4707E.E7A6D897>