Mail Archives: cygwin/1996/11/20/23:03:30
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".
- Raw text -