Bug #44217 [Nab->ReO]: Output after stdout/stderr closed cause immediate exit with status 0
| From: | cmb@php.net | Date: | Tue, 19 Jun 2018 10:13:17 +0000 |
| Subject: | Bug #44217 [Nab->ReO]: Output after stdout/stderr closed cause immediate exit with status 0 | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-215784@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=44217&edit=1
ID: 44217
Updated by: cmb@php.net
Reported by: exe at travian dot org
-Summary: Output after stdout/stderr closed cause immediate
exit
+Summary: Output after stdout/stderr closed cause immediate
exit with status 0
-Status: Not a bug
+Status: Re-Opened
Type: Bug
-Package: Filesystem function related
+Package: CGI/CLI related
Operating System: *
PHP Version: 5.*, 6CVS (2009-01-21)
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
Re-opening wrt. <https://github.com/php/php-src/pull/3306>.
Previous Comments:
------------------------------------------------------------------------
[2018-06-15 06:52:01] robberphex at gmail dot com
When ignore_user_abort is 0,
php should exit with non-zero code: https://github.com/php/php-src/pull/3306
------------------------------------------------------------------------
[2009-07-23 22:41:57] jani@php.net
See bug #48803, using ignore_user_abort=1 "fixes" this for you.
------------------------------------------------------------------------
[2008-06-28 19:35:29] work at anomalizer dot net
I guess what you are asking for is something like this to happen when you close STDOUT
dup2(open("/dev/null", O_WRONLY), 1);
------------------------------------------------------------------------
[2008-04-27 13:40:51] duane at e164 dot org
The solution to stopping this output is rather simple. After you close the stdin/stdout/stderr open
3 new file descriptors to /dev/null and all output goes bye bye. eg.
fclose(STDIN);
fclose(STDOUT);
fclose(STDERR);
$fp1 = fopen('/dev/null', 'r');
$fp2 = fopen('/dev/null', 'w');
$fp3 = fopen('/dev/null', 'w');
------------------------------------------------------------------------
[2008-02-25 11:54:22] exe at travian dot org
I'd expect php to discard every output after STDOUT is closed, instead of doing a silent exit
(which is hard to track because no error handler or shutdown function is called). Another option (if
output in this situation is considered to be an error) would be to trigger a warning/fatal and/or
call the shutdown function. This would, at least, make it possible to track this issue.
I have to close STDOUT and STDERR in a daemonized processes to detach from the controlling terminal.
------------------------------------------------------------------------
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=44217
--
Edit this bug report at https://bugs.php.net/bug.php?id=44217&edit=1