Window freeze during fgets from pipe

From: Date: Sun, 06 Jun 2004 15:42:15 +0000
Subject: Window freeze during fgets from pipe
Groups: php.gtk.general 
Request: Send a blank email to php-gtk-general+get-4623@lists.php.net to get a copy of this message
I'm trying to call a command line utility and record the output into a GtkText widget. I'm using proc_open() to execute the command and then I start a cycle which reads from the process stdout pipe like from a regular file and adds each line to the text widget. The problem is that sometimes it takes a while for any output to come through and during that time the entire window is frozen. The reading cycle is this: while(!feof($pipes[1])) { $line=fgets($pipes[1],1024); $DATA['widgets']['outputText']->insert_text($line, $DATA['widgets']['outputText']->get_length()); while(Gtk::events_pending()) Gtk::main_iteration(); } As you can see, I've tried to overcome the issue with forced iterations. I've also tried using gtk::timeout_add() thinking it won't be affected by the freeze, but it is. The same happens with register_tick_function(). Apparently, the pause occurs while fgets() is executed and is waiting to receive something from the pipe. Does anyone have any idea about how I could overcome this issue? Is there any other background-executing statement that will execute in spite of fgets()? Is there a non-blocking way to read from a stream, such as connecting an event that will only get triggered when something comes through? Perhaps I'm going about this the wrong way in the first place? -- Ciprian Popovici

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