Bug #71804 [Opn]: proc_close does not return exit code

From: Date: Tue, 22 Mar 2016 00:00:03 +0000
Subject: Bug #71804 [Opn]: proc_close does not return exit code
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-200015@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=71804&edit=1

 ID:                 71804
 User updated by:    mark at mpen dot ca
 Reported by:        mark at mpen dot ca
 Summary:            proc_close does not return exit code
 Status:             Open
 Type:               Bug
 Package:            Program Execution
 Operating System:   Ubuntu 14.10
 PHP Version:        7.0.4
 Block user comment: N
 Private report:     N

 New Comment:

Oh really? I thought that was the same configuration we were running on PHP 5.6 according to our
internal documentation, but I guess not! Sorry for the dupe. I guess our PHP 5.6 install didn't
have it after all.


Previous Comments:
------------------------------------------------------------------------
[2016-03-21 21:04:16] as@php.net

I agree it should at least be documented somewhere.

By the way, this doesn't appear to be a new bug. After investigating I found many bugs
reporting the same behavior. Google query: site:bugs.php.net "proc_close"
"--enable-sigchild"

You should file a bug with the maintainer of the PHP 7 package you used. They should recompile
without --enable-sigchild.

------------------------------------------------------------------------
[2016-03-21 16:20:20] mark at mpen dot ca

Thank you for investigating, disabling sigchild fixed it for me. I don't *think* I need
sigchild anymore (I'm not entirely sure what it does), so this should be fine for me, but
something should probably be done about this to warn others because it looks like a breaking change.

------------------------------------------------------------------------
[2016-03-20 05:43:01] as@php.net

In the PHP 7 trace, I noticed that the parent process is setting a signal handler for SIGCHLD.
(Search for "rt_sigaction(SIGCHLD".) Searching backwards from there, I was able to
reproduce the bug by recompiling with --enable-sigchild (already present in your
binary). This switch is from 15+ years ago (commit 674f4bac) and causes PHP to reap all child
processes asynchronously:

https://github.com/php/php-src/blob/PHP-7.0.4/main/main.c#L1515-L1523

proc_close also attempts to reap the child process here:

https://github.com/php/php-src/blob/PHP-7.0.4/ext/standard/proc_open.c#L228

but at that point it has already been reaped by sigchld_handler so waitpid
returns -1.

The only way I can think of fixing this is to keep track of exit statuses in
sigchld_handler and check that in proc_close if PHP_SIGCHILD
is defined. Very ugly.

Alternatively we might be able to deprecate --enable-sigchild.

For your specific case, you likely do not need --enable-sigchild, and recompiling
without it should fix your issue.

------------------------------------------------------------------------
[2016-03-17 16:12:46] mark at mpen dot ca

Not sure how to attach files; it wouldn't let me submit them as patches. I've uploaded
them to pastebin:

- PHP 5.6 strace: http://pastebin.com/SNuJGAZW
- PHp 7.0.4 strace: http://pastebin.com/akrFjzpT

------------------------------------------------------------------------
[2016-03-15 04:22:56] as@php.net

Having trouble reproducing. Can you attach strace output for 5.6 and 7? Invoke like:

    $ strace -ttt -T -f -s1024 -o strace.log php test.php

Thanks.

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=71804


--
Edit this bug report at https://bugs.php.net/bug.php?id=71804&edit=1


Thread (7 messages)

« previous php.bugs (#200015) next »