From: wrichard AT direct DOT ca (Wade Richards) Subject: Re: fork() 20 Nov 1996 23:03:30 -0800 Sender: daemon AT cygnus DOT com Approved: cygnus DOT gnu-win32 AT cygnus DOT 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 AT mail DOT direct DOT ca X-Mailer: Windows Eudora Light Version 1.5.4 (32) Original-To: Fabricio Chalub Original-Cc: gnu-win32 AT cygnus DOT com Original-Sender: owner-gnu-win32 AT cygnus DOT 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 AT Direct DOT 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 AT cygnus DOT com" with one line of text: "help".