Mail Archives: cygwin/2009/10/15/10:34:31
I'm trying to track down a rather weird problem. I don't have an STC
because none of my attepted STCs exhibit the problem. Schematically, I
have:
=============================================
pid_t pid = fork();
if (pid < 0) {
printf("fork failed\n");
exit (1);
}
if (pid > 0) {
/* parent */
printf("parent: child pid=%d\n", pid);
sleep(30);
exit(0);
}
/* child */
printf("child lives!");
sleep(30);
exit(0);
=============================================
although the actual app is much more complicated, AND an STC based on
the above actually works as expected. But, in the actual app, what
happens is:
1) fork appears to succeed, because I see:
parent: child pid=xxx
2) but fork fails, because I never see:
child lives!
Worse, I never see the pid xxx show up in 'ps' output, even though I
have plenty of time (30 seconds) to spot it (and STCs based on the above
simplification do work as expected; I see 'child lives!' and the process
shows up in 'ps').
I even tried (in the actual app) other methods of indication than
printing to some FILE*, since maybe stdout got scrogged by fork, such as:
a) writing to an inherited fd other than 0,1,2
b) writing to a brand new fd or FILE* opened by the child
c) simply touching a "sentinel" file to change its atime
Nothing. For all I can tell, the fork() fails to *actually* produce a
child process -- even though the *parent* seems to think one has been
created, and has a pid for the so-called child. Which doesn't actually
exist.
Can anybody think of a reason that might cause this behavior? I'm using
stock cygwin-1.7.0-62...
--
Chuck
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
- Raw text -