php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #49694 proc_open, stream_select function hangs on return
Submitted: 2009-09-27 22:57 UTC Modified: 2010-02-07 17:40 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: compconsultant at yahoo dot com Assigned:
Status: Not a bug Package: Streams related
PHP Version: 5.2.11 OS: Centos 5.3
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: compconsultant at yahoo dot com
New email:
PHP Version: OS:

 

 [2009-09-27 22:57 UTC] compconsultant at yahoo dot com
Description:
------------
Using proc_open to open a pipe to a command, and, putting stream_select 
into a function, hangs upon return from that function.  

Reproduce code:
---------------
<?php
	function SelectStream($StreamsArray) {
		$Null = array();
		$timeout = NULL;
		stream_select($StreamsArray, $Null, $Null, $timeout);
		echo "After select\n";
		return FALSE;
	}
$ProcDescriptor = array(1 => array("pipe", "w"));
$Resource = proc_open("tail -F /var/log/mail.log", $ProcDescriptor, $Pipes, NULL, NULL, array("binary_pipes" => TRUE));
if ($Resource === FALSE) die("proc_open failed\n");
$ProgResource = $Pipes[1];
/*
$ProgResource = popen("tail -F /var/log/mail.log", "r");
if ($ProgResource === FALSE) die("Could not open the PIPE\n");
*/
$Streams[] = $ProgResource;
$Resource = SelectStream($Streams);
echo "ok\n";
?>

Expected result:
----------------
I expect ok to be displayed. If you replace proc_open with popen 
(uncomment the lines), the same function returns fine (ok displayed). If 
you remove the stream_select, it also returns fine. 

Actual result:
--------------
The string ok is not displayed, the statement is never reached. After 
select is displayed. So, it is hanging on the return statement.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-10-05 14:54 UTC] compconsultant at yahoo dot com
Same result, no difference, no "ok" displayed
 [2009-12-18 11:32 UTC] jani@php.net
Isn't it tail that "hangs" since you use -F instead of -f ?
 [2009-12-21 05:30 UTC] compconsultant at yahoo dot com
No, -F is correct. If the log file is rotated, tail will follow it.
 [2010-02-07 05:50 UTC] compconsultant at yahoo dot com
Ok, I give up. I can see no one wants to fix this so let other people 
have the same problem. To cancel bugs after 1 week with no feedback is 
absurd. Doesn't make it not a bug!

I will not report any future bugs either.
 [2010-02-07 17:40 UTC] jani@php.net
boohoo..
 [2011-03-04 12:31 UTC] working dot good at gmailc dot om
Why to use steam_select on $ProgResource, and not on $Pipes ? This is really the reason it doesnt work.
 [2011-03-04 12:31 UTC] working dot good at gmailc dot om
Why to use steam_select on $ProgResource, and not  $Pipes ? This is really the reason it doesnt work.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Dec 30 14:01:28 2024 UTC