From owner-freebsd-hackers Sun Sep 14 03:17:28 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.7/8.8.7) id DAA04014 for hackers-outgoing; Sun, 14 Sep 1997 03:17:28 -0700 (PDT) Received: from lestat.nas.nasa.gov (lestat.nas.nasa.gov [129.99.50.29]) by hub.freebsd.org (8.8.7/8.8.7) with ESMTP id DAA04009 for ; Sun, 14 Sep 1997 03:17:24 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by lestat.nas.nasa.gov (8.8.6/8.6.12) with SMTP id DAA01459; Sun, 14 Sep 1997 03:11:15 -0700 (PDT) Message-Id: <199709141011.DAA01459@lestat.nas.nasa.gov> X-Authentication-Warning: lestat.nas.nasa.gov: localhost [127.0.0.1] didn't use HELO protocol To: Simon Shapiro Cc: freebsd-hackers@freebsd.org Subject: Re: What is wrong with this snipet? Reply-To: Jason Thorpe From: Jason Thorpe Date: Sun, 14 Sep 1997 03:11:10 -0700 Sender: owner-freebsd-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk On Sat, 13 Sep 1997 16:34:42 -0700 (PDT) Simon Shapiro wrote: > Why would the following segfault on 6 of the 10 iterations? In the FreeBSD implementation of RFMEM (which does not match Plan 9's), the child gets the same stack as the parent. If you "return" in the child, someone's stack gets munched. > > int > main(int argc, char **argv, char **argp) > { > int ndx; > > for ( ndx = 0; ndx < 10; ndx++ ) { > switch ( rfork(RFPROC|RFNOWAIT|RFFDG|RFMEM) ) { > case -1: > (void)fprintf(stderr, "%s ERROR: Failed to fork (%s)\n", > argv[0], strerror(errno)); > break; > case 0: > return(0); > } > } > > return(0); > } > > --- > > > Sincerely Yours, (Sent on 13-Sep-97, 16:31:40 > by XF-Mail) > > Simon Shapiro Atlas Telecom > Senior Architect 14355 SW Allen Blvd., Suite 130 Beaverton OR 97005 > Shimon@i-Connect.Net Voice: 503.643.5559, Emergency: 503.799.2313 Jason R. Thorpe thorpej@nas.nasa.gov NASA Ames Research Center Home: +1 408 866 1912 NAS: M/S 258-6 Work: +1 415 604 0935 Moffett Field, CA 94035 Pager: +1 415 428 6939