Say I have a large, complex Gtk2-Perl GUI application that needs to work on both Linux and Windows. This application also has to start and communicate with a second program, that accepts newline-terminated commands on stdin and responds on stdout.
The problem is that for the GUI to remain responsive reading the application's responses must be done in a non-blocking way. As far as I know, there is no way to put an anonymous pipe into non-blocking mode on Windows, so I can't use open2 or similar because reads would block. I can't or shouldn't use threads because, to quote the documentation, "please lie down and wait until the feeling passes", and they are "discouraged" anyway.
The only way I could think of is to use an external utility, netcat, to start the console program and tie its stdin/stdout to a local socket, and then from the perl program connect to that socket, because those at least I can use in non-blocking mode even on Windows. However, even that was not straightforward, because apparently there is a bug in Glib that makes Glib::IO watchers unusable on recent perls (specifically, the entire event loop freezes the first time any data is received on the socket if perl is 5.18 or newer).
So how to do it in a sane way? Is it possible at all?
In reply to Gtk2 app on Windows, driving a background process by kikuchiyo
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |