Re: Gtk::input_add() for a popen() filehandle?

From: Date: Mon, 01 Apr 2002 12:44:18 +0000
Subject: Re: Gtk::input_add() for a popen() filehandle?
References: 1 2 3  Groups: php.gtk.general 
Request: Send a blank email to php-gtk-general+get-1688@lists.php.net to get a copy of this message
Ahh, after a little investigation :) http://mail.gnome.org/archives/gtk-list/1998-July/msg00680.html notice the magic fileno(stream) - I suspect if you change RETURN_LONG(gtk_input_add_full(*source, condition, NULL,
                                (GtkCallbackMarshal)php_gtk_input_marshal,
                                data, php_gtk_destroy_notify));
} to RETURN_LONG(gtk_input_add_full(fileno(*source), condition, NULL,
                                (GtkCallbackMarshal)php_gtk_input_marshal,
                                data, php_gtk_destroy_notify));
} It may work with popen, - now if that works.... did you want to work out a patch that works for both file and popen :) regards alan James Cameron wrote:
G'day Alan, Thanks for your comments on this. I've just tried doing as you suggest; adding a debugging php_error call to gtk.overrides, but I'm afraid I don't understand the output. What I got for a popen() filehandle was ... Debugging input_add : 842e8d0 138602704 Despite changing the rsrc_type to check against php_file_le_popen() not php_file_le_fopen(), the input function is not being called. So I worry that the PHP popen and fopen types are not compatible ... that is they are not both a plain FILE pointer as they are in C. Can you point to the appropriate place in the PHP source? I don't know my way around it yet. My callback function ... function on_start_activate() { global $fp, $gu; $fp = popen("sleep 1;date;sleep 1;date;sleep 1;date", "r"); $gu = Gtk::input_add($fp, GDK_INPUT_READ, "reader"); } ... and the reader function ... function reader() { global $fp, $gu; echo "reader: entry\n"; $line = fgets($fp, 1024); echo "reader: $line"; if (feof($fp)) {
     echo "reader: eof after fgets\n"; pclose($fp); return false; }
return true; } However, reader() is not being called.


« previous php.gtk.general (#1688) next »