waitpid() does not wait for process exit
waitpid() does not wait for process exit
- Subject: waitpid() does not wait for process exit
- From: Anatol Pomozov <email@hidden>
- Date: Tue, 03 May 2011 21:13:29 -0700
Hi,
I am working on porting tup build tool to Macosx
https://github.com/anatol/tup/tree/fuse
There is a piece of code that works fine on Linux but fails on osx for
some reason. I am trying to understand why. The exact failure point is
the waitpid() function at
https://github.com/anatol/tup/blob/fuse/src/tup/server/fuse_server.c
line 231
Here is a simplified version of the code:
pid_t pid = fork();
if (pid == 0) {
// fuse fs is served by a thread in the parent process
chdir(PATH_TO_FUSE_FS);
execl("gcc compile foo.c");
}
if (waitpid(pid, &status, 0) < 0) {
perror("waitpid);
printf("fail waitpid = %d\n", pid);
}
The code looks pretty much typical, everything seems fine. But the
code fails on macosx - waitpid() returns ECHILD error. waitpid()
thinks that there is no any child with such pid. Hmm, why?
Here is the output of "sudo dtruss ./tup upd -j" maybe it can be
useful https://gist.github.com/273ef2e45ceb11824241
The most interested part is near line 5595 where it prints "fail waitpid"
58952/0x19dcc: wait4(0xE64F, 0x100780D9C, 0x0) = -1 Err#10
it fails on waiting of the process 58959 (in hex it is 0xE64F), but
the thing is that the process exists - check the logs below at lines
6110. And it makes me puzzled. I carefully read "man waitpid" and did
not find anything that can shed any light on this.
I am suspecting that either child or parent process (macfuse??) does
something that makes kernel think that there is no relation between
these 2 processes anymore.
RESUME: waitpid() for some reason returns ECHILD for a process that
was just recently forked. It does not conform to man page. Is there
reason why waitpid() fails?
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden