|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #72256 echo statement on invalid fd cause php to abort
Submitted: 2016-05-23 07:32 UTC Modified: 2016-05-27 05:13 UTC
From: prinbra at gmail dot com Assigned:
Status: Open Package: *General Issues
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2016-05-23 07:32 UTC] prinbra at gmail dot com
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!


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2016-05-25 20:46 UTC]
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.

 [2016-05-27 05:13 UTC] prinbra at gmail dot com
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?

fprintf(STDOUT, "hello, world\n");
fprintf(STDOUT, "hello, world2\n");
fprintf(STDERR, "hello, world2 in stderr\n");

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.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sat Oct 16 04:03:33 2021 UTC