Bug #72256 [Opn]: echo statement on invalid fd cause php to abort
| From: | prinbra at gmail dot com | Date: | Fri, 27 May 2016 05:13:03 +0000 |
| Subject: | Bug #72256 [Opn]: echo statement on invalid fd cause php to abort | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-201292@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=72256&edit=1
ID: 72256
User updated by: prinbra at gmail dot com
Reported by: prinbra at gmail dot com
Summary: echo statement on invalid fd cause php to abort
Status: Open
Type: Bug
Package: *General Issues
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
er, my point isï¼ may be the php process shouldn't quit if echo failed.
the fail of fprintf does not cause php to quit? why echo is so special and so fragile?
example:
fprintf.php
<?php
fprintf(STDOUT, "hello, world\n");
fclose(STDOUT);
fprintf(STDOUT, "hello, world2\n");
fprintf(STDERR, "hello, world2 in stderr\n");
output:
hello, world
PHP Warning: fprintf(): 2 is not a valid stream resource in /tmp/t.php on line 4
hello, world2 in stder
however, if change fprintf to echo, php will quit early.
Previous Comments:
------------------------------------------------------------------------
[2016-05-25 20:46:27] ab@php.net
Thanks for the report. When user is logged out, the whole session becomes invalid. This should be
solvable by using nohup or running PHP in screen/tmux.
Thanks.
------------------------------------------------------------------------
[2016-05-23 07:32:10] prinbra at gmail dot com
Description:
------------
on cli environment, when the stdout of php becomes unavailable, eg: user run php in background and
logged out of their ssh connection.
a echo statement will cause php process to exit immediately!
strace output:
14937 12:22:18.958295 write(1, "running\n", 8) = -1 EIO (Input/output error)
then php just silently quit!
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=72256&edit=1