Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 20 Mar 1999 12:39:16 +0000
From:      Mark Ovens <marko@uk.radan.com>
To:        Samit Pal <samit@usa.ltindia.com>
Cc:        FreeBSD-Questions@freebsd.org
Subject:   Re: rfork()
Message-ID:  <19990320123916.A266@marder-1.localhost>
In-Reply-To: <36F37127.7C0B121D@usa.ltindia.com>; from Samit Pal on Sat, Mar 20, 1999 at 03:28:00PM %2B0530
References:  <36F37127.7C0B121D@usa.ltindia.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, Mar 20, 1999 at 03:28:00PM +0530, Samit Pal wrote:
> 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.

I know a "me too" post doesn't help you solve the problem for you,
but I've got almost exactly the same problem. I have been writing
some test programs to get my head around inter-process comms and
finally got something working whereby the parent prints out a string
that the child process sends to it. Worked fine under 2.2.8 but
now I've u/g to 3.1 it displays the same behaviour as yours. The
parent printf()'s it's message, but without the string from the
child. Adding a sleep() to both processes allows me to confirm
using ps(1) that both processes are in fact running.

The point of this message is to ask you that if you get to the
bottom of it will you post the solution to the list, or to me
privately please. Thanks.

BTW, I'm using fork() not rfork(). I'm confused by this "bug".
fork() obviously works because the OS runs, shells for example rely
on fork().

> 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
> 

-- 
      FreeBSD - The Power To Serve http://www.freebsd.org
      My Webpage http://www.users.globalnet.co.uk/~markov
_______________________________________________________________
Mark Ovens, CNC Apps Engineer, Radan Computational Ltd. Bath UK
CAD/CAM solutions for Sheetmetal Working Industry
mailto:marko@uk.radan.com                  http://www.radan.com



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?19990320123916.A266>