Vyacheslav Dikonov wrote:
The problem is that the event callback seems to be triggered only once when EOF is received. I need it to occur either when a newline appears in the pipe (backend prints "\n") or by every single character. I have no clues on how to make the watcher act as needed and my frontend draw messages one-by-one instead of one bulk line after an hour long wait.
I think the problem is the buffered I/O in your callback. The Glib watcher calls the callback when events on the low level Unix file descriptor occur. When you read a line using <IN> Perl will happily slurp more than one line into its internal buffer and Glib won't call your callback again, since from its view everything was read. So you should use only sysread() and syswrite() on filehandles watched by Glib. The example in Gtk2::Helper's manpage (which I wrote long time ago when I was much more ignorant than today ;) suffers from this issue as well, but I just committed a fixed version to CVS. Regards, Joern -- Think before you code. And while you're doing it probably won't hurt. ;)
Attachment:
pgpFMcgBOjDad.pgp
Description: PGP signature