php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43546 Strange behaviour after setting stream_set_blocking()
Submitted: 2007-12-09 20:33 UTC Modified: 2007-12-10 09:41 UTC
From: martzy at gmail dot com Assigned:
Status: Not a bug Package: Streams related
PHP Version: 5.2.5 OS: FreeBSD 6.2-RELEASE
Private report: No CVE-ID: None
 [2007-12-09 20:33 UTC] martzy at gmail dot com
Description:
------------
When running a PHP script as CLI, after setting stream_set_blocking($x,0), invoking an infinite loop which includes a print statement causes spontaneous script termination after an indeterminate number of iterations.

Omitting stream_set_blocking() eliminates the problem.

Tested and confirmed this behaviour on PHP 5.2.3 and PHP 5.2.5 on several FreeBSD systems.

Reproduce code:
---------------
This works as expected:

<?php

stream_set_blocking(STDIN,0);

do {

} while(TRUE);

?>


However, after introducing a print statement to the loop, the script appears to spontaneously terminate after a number of iterations.

<?php

stream_set_blocking(STDIN,0);

do {
        print "!";
} while(TRUE);

?>



Expected result:
----------------
Script should loop indefinately.

Actual result:
--------------
Script terminates on it's own. Any code following the loop is not executed.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-12-10 09:41 UTC] jani@php.net
Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same. 

Thank you for your interest in PHP.

See bug #34972
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Wed Oct 23 21:01:33 2019 UTC