site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:date:message-id:subject:from:to :content-type; bh=VXSplRMultyBGtE3VJGcyaPBk+wq/KbxbzlJXwKSLPM=; b=DgOCn7TGeIhslsR/HegW7QJy+z/OCJCSpe9Q1eRcRrxX5Nf7ddjYbQFi+tpt0aHqyB +gFX73Z4bNz39rzACVNJOXH+Gc4qSqQDZr6njVU/BWvuuHaeNJBgA0PATfPonCJwcBpL M3s/mhonRv0EqQppJKA5StgF/H5WAc52/+pho= Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=BB1KtziJ7cXhg2GMxidsZGgPmSReTS48Dl2It+Ofv7rWOehE5727ONEKf6YIsuXpok Wlfww9ElM4XVvf04v8U5dfbpNlk3SBty3SoUxanGNwfVtqL4FkNoGIdzMiFP44UAmnOu mV9s0hf5HL6KRPIaTIIV0akyb5E3WiGv81avE= 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 (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... This email sent to site_archiver@lists.apple.com