From: exe at travian dot org Operating system: GNU/Linux Kernel 2.6.18 PHP version: 5.2.5 PHP Bug Type: Filesystem function related Bug description: Output after stdout/stderr cause immediate exit
Description: ------------ If STDOUT and/or STDERR are closed, output by the php script cause the interpreter to exit immediately. According to strace output, php tries to write to the closed STDOUT file handle, causing a "Bad file descriptor" error and exit of the interpreter: [...] close(1) = 0 [...] write(1, "foo", 3) = -1 EBADF (Bad file descriptor) close(0) = 0 close(2) = 0 [...] exit_group(0) = ? Process 19177 detached Reproduce code: --------------- <?php fclose(STDOUT); print "foo"; sleep(10); ?> Expected result: ---------------- No output, php sleeping for 10 seconds. Actual result: -------------- php exits immediately, strace shows an "Bad file descriptor" on the write() try to STDOUT: [...] read(3, "<?php\nfclose(STDOUT);\n\nprint \"fo"..., 8192) = 51 read(3, "", 4096) = 0 read(3, "", 8192) = 0 close(3) = 0 munmap(0x2b1dce200000, 4096) = 0 close(1) = 0 munmap(0x2b1dce202000, 4096) = 0 write(1, "foo", 3) = -1 EBADF (Bad file descriptor) close(2) = 0 close(0) = 0 munmap(0x2b1dce201000, 4096) = 0 munmap(0x2b1dce1bf000, 266240) = 0 mmap(NULL, 266240, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2b1dce1bf000 setitimer(ITIMER_PROF, {it_interval={0, 0}, it_value={0, 0}}, NULL) = 0 munmap(0x2b1dce1bf000, 266240) = 0 brk(0xd36000) = 0xd36000 exit_group(0) = ? Process 19196 detached -- Edit bug report at http://bugs.php.net/?id=44217&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=44217&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=44217&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=44217&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=44217&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=44217&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=44217&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=44217&r=needscript Try newer version: http://bugs.php.net/fix.php?id=44217&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=44217&r=support Expected behavior: http://bugs.php.net/fix.php?id=44217&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=44217&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=44217&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=44217&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=44217&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=44217&r=dst IIS Stability: http://bugs.php.net/fix.php?id=44217&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=44217&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=44217&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=44217&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=44217&r=mysqlcfg