#48803 [Asn]: fprintf(STDOUT, ...) and printf(...) behave differently and affect STDERR

From: Date: Sat, 16 Jan 2010 23:27:24 +0000
Subject: #48803 [Asn]: fprintf(STDOUT, ...) and printf(...) behave differently and affect STDERR
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-3724@lists.php.net to get a copy of this message
ID: 48803 Updated by: jani@php.net Reported By: andrey dot vihrov at gmail dot com Status: Assigned Bug Type: Documentation problem Operating System: Gentoo Linux amd64 PHP Version: 5.*, 6CVS (2009-07-06) -Assigned To: jani +Assigned To: bjori New Comment: If you really think I can remember what was needed half a year ago, you must be dreaming. Figure it out yourself. Previous Comments: ------------------------------------------------------------------------ [2010-01-16 22:18:49] bjori@php.net I don't have the slightest idea what is expected to be documented here. Could you please explain (preferably with a copy&pasteable example) what should be documented? ------------------------------------------------------------------------ [2009-07-07 12:59:20] jani@php.net Actually this is by design. Since PHP is meant primarily for web usage, such "weird" things are necessary like using ignore_user_abort(true); to get full "power" for console scripts. This should be mentioned in relevant parts in documentation. printf() mainly since that is especially tricky if you don't know things works under the hood. ------------------------------------------------------------------------ [2009-07-06 13:00:58] jani@php.net As a workaround, just set 'ignore_user_abort=1' in your CLI ini. ------------------------------------------------------------------------ [2009-07-06 11:58:07] andrey dot vihrov at gmail dot com Hi, thanks for the explanation. Quite simply errors can occur when writing to any real media (leaving the terminal aside). For a simple example, consider a PHP script that is being started with its output being redirected to a file. If the target filesystem, e. g., runs out of space or encounters an I/O error (like network fs being disconnected), the script will want to exit unsuccessfully and, optionally, inform the user about it using STDERR. If this is not the case, the user will assume things went good, which does not correspond to reality and may lead to further failures. The example provided in previous comment is the classical one to check if software handles I/O errors correctly, so I used it for demonstration. ------------------------------------------------------------------------ [2009-07-05 11:20:37] sjoerd-php at linuxonly dot nl Thank you for your bug report. The problem is not that STDERR is affected, but that the script is terminated immediately. Furthermore, it is not specific for printf. time php -r 'echo 'a'; sleep(5);' > /dev/full Expected: real 0m5.030s Actual: real 0m0.030s Your contrived example writes to /dev/full, which obviously fails. Do you have a more real-life example where writing to STDOUT fails? ------------------------------------------------------------------------ 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 http://bugs.php.net/48803 -- Edit this bug report at http://bugs.php.net/?id=48803&edit=1

« previous php.doc.bugs (#3724) next »