From owner-freebsd-questions Sat Mar 20 4:44:17 1999 Delivered-To: freebsd-questions@freebsd.org Received: from post-20.mail.demon.net (post-20.mail.demon.net [194.217.242.27]) by hub.freebsd.org (Postfix) with ESMTP id 2ED4514C93 for ; Sat, 20 Mar 1999 04:44:15 -0800 (PST) (envelope-from marko@uk.radan.com) Received: from [158.152.75.22] (helo=uk.radan.com) by post-20.mail.demon.net with smtp (Exim 2.10 #2) id 10OL6X-0004Z7-0K; Sat, 20 Mar 1999 12:43:54 +0000 Organisation: Radan Computational Ltd., Bath, UK. Phone: +44-1225-320320 Fax: +44-1225-320311 Received: from marder-1. (rasnt-1 [193.114.228.211]) by uk.radan.com (8.6.10/8.6.10) with ESMTP id MAA01446; Sat, 20 Mar 1999 12:42:25 GMT Received: (from marko@localhost) by marder-1. (8.9.2/8.8.8) id MAA00330; Sat, 20 Mar 1999 12:39:16 GMT (envelope-from marko) Date: Sat, 20 Mar 1999 12:39:16 +0000 From: Mark Ovens To: Samit Pal Cc: FreeBSD-Questions@freebsd.org Subject: Re: rfork() Message-ID: <19990320123916.A266@marder-1.localhost> References: <36F37127.7C0B121D@usa.ltindia.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.95.3i In-Reply-To: <36F37127.7C0B121D@usa.ltindia.com>; from Samit Pal on Sat, Mar 20, 1999 at 03:28:00PM +0530 Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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 > 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