#41875 [Opn->Bgs]: io_add_watch can't detect HUPs
| From: | auroraeosrose@php.net | Date: | Wed, 18 Jul 2007 20:17:03 +0000 |
| Subject: | #41875 [Opn->Bgs]: io_add_watch can't detect HUPs | ||
| References: | 1 | Groups: | php.gtk.dev |
| Request: | Send a blank email to php-gtk-dev+get-3923@lists.php.net to get a copy of this message | ||
ID: 41875
Updated by: auroraeosrose@php.net
Reported By: sebastianmarconi at gmail dot com
-Status: Open
+Status: Bogus
Bug Type: PHP-GTK related
Operating System: Windows XP
PHP Version: 5.2.3
New Comment:
You need to add code to detect HUP | IN - hup is never being called
separately so the second watch is never being fired
<?php
function out($pipe) {
echo "STDOUT\n";
echo stream_get_contents($pipe);
}
function hupin($pipe){
echo "STDOUT\n";
echo stream_get_contents($pipe);
echo "HUP\n";
Gtk::main_quit();
return false;
}
function hup($pipe){
echo "HUP\n";
Gtk::main_quit();
return false;
}
$pipes = null;
$descriptor = array(
0 => array("pipe", "r"), // stdin
1 => array("pipe", "w"), // stdout is a pipe that the child
will write to
2 => array("pipe", "w") // stderr
);
$cmd = 'dir';
$p = proc_open($cmd, $descriptor, $pipes);
Gtk::io_add_watch($pipes[1],GTK::IO_IN, 'out');
Gtk::io_add_watch($pipes[1],GTK::IO_HUP, 'hup');
Gtk::io_add_watch($pipes[1],GTK::IO_HUP | GTK::IO_IN, 'hupin');
Gtk::main();
echo "EXIT\n";
fclose($pipes[0]);
fclose($pipes[1]);
fclose($pipes[2]);
?>
Previous Comments:
------------------------------------------------------------------------
[2007-07-18 19:02:55] bob at kateos dot org
works as expected on Linux.
------------------------------------------------------------------------
[2007-07-02 19:04:10] sebastianmarconi at gmail dot com
Description:
------------
It seems that Gtk::io_add_watch
can't detect HUP conditions using
beta Windows binary with Gtk+ 2.10.
In some cases the only workaround that I've found is to look the
process status info [1] in the STDOUT callback (sometimes it sends IO_IN
signals constantly), but randomly losses some information.
[1]
<?php
$status = proc_get_status($proc_id);
if (! $status['running']) {
$this->io_hup($pipe);
}
?>
Reproduce code:
---------------
<?php
function out($pipe) {
echo "STDOUT\n";
echo stream_get_contents($pipe);
}
function hup($pipe){
echo "HUP\n";
Gtk::main_quit();
return false;
}
$pipes = null;
$descriptor = array(
0 => array("pipe", "r"), // stdin
1 => array("pipe", "w"), // stdout is a pipe that the child
will write to
2 => array("pipe", "w") // stderr
);
$cmd = 'dir';
$p = proc_open($cmd, $descriptor, $pipes);
Gtk::io_add_watch($pipes[1],Gtk::IO_IN, 'out');
Gtk::io_add_watch($pipes[1],Gtk::IO_HUP, 'hup');
Gtk::main();
echo "EXIT\n";
fclose($pipes[0]);
fclose($pipes[1]);
fclose($pipes[2]);
?>
Expected result:
----------------
STDOUT
[Dir contents]
HUP
EXIT
Actual result:
--------------
STDOUT
[The script hangs]
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=41875&edit=1