From: wrichard@direct.ca (Wade Richards)
Subject: Re: fork()
20 Nov 1996 23:03:30 -0800
Sender: daemon@cygnus.com
Approved: cygnus.gnu-win32@cygnus.com
Distribution: cygnus
Message-ID: <1.5.4.32.19961121060622.0068edc8.cygnus.gnu-win32@mail.direct.ca>
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
X-Sender: wrichard@mail.direct.ca
X-Mailer: Windows Eudora Light Version 1.5.4 (32)
Original-To: Fabricio Chalub <miguelb@omega.lncc.br>
Original-Cc: gnu-win32@cygnus.com
Original-Sender: owner-gnu-win32@cygnus.com

At 19:29 20/11/96 -0300, Fabricio Chalub wrote:
}This simple program:
}main () {
}  fork();
}  printf("Hi");
}}
[ fails...]

I tried your program, and noticed that it would sometimes work, and
sometimes fail.  Looking a bit harder, I noticed that it seems only to blow
up if the original process exits before the child process.  For example:

main () {
  int pid = fork();
  printf("after fork\n" );
  if (pid) sleep(1);
}

This program always works, and if you change the (pid) to (!pid), it always
fails.  For a work-around, you can always wait for the child process before
exiting the main process:

main () {
  int s, p = fork();
  printf("Hi\n" );
  if (p) waitpid(p,&s,0);
}

        --- Wade
----------
Wade Richards    -= WRichard@Direct.CA =- 
"Never attribute to malice what can adequately be explained by stupidity."

-
For help on using this list, send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".
