Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 19 Aug 1998 10:43:09 -0500 (EST)
From:      Alfred Perlstein <bright@www.hotjobs.com>
To:        hackers@FreeBSD.ORG
Subject:   sfork()?
Message-ID:  <Pine.BSF.3.96.980819095759.17267L-100000@bright.fx.genx.net>
In-Reply-To: <199808191303.PAA10187@sos.freebsd.dk>

next in thread | previous in thread | raw e-mail | index | archive | help

can someone explain why this doesn't work?

(the child process just segfaults, even without the printfs)

----- CUT 

#include <stdio.h>
#include <unistd.h>

volatile int t=0;

int main(void){

   pid_t pid;

   if(pid = rfork(RFPROC | RFMEM)){
      printf("(parent)pid = %d\n",pid);
      while(1){
         printf("%d\n",t);
         sleep(1);
      }
   } else {
      printf("doesn't die here...");
      t = 1;
      printf("changed t... ");
      sleep(10000);
   }

   printf("pid = %d about to exit\n",pid);
   return(0);
}
 
----- END


Alfred Perlstein - Programmer, HotJobs Inc. - www.hotjobs.com
-- There are operating systems, and then there's BSD.
-- http://www.freebsd.org/


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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.3.96.980819095759.17267L-100000>