kikuchiyo has asked for the wisdom of the Perl Monks concerning the following question:
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?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Gtk2 app on Windows, driving a background process
by marioroy (Prior) on May 31, 2017 at 03:08 UTC | |
|
Re: Gtk2 app on Windows, driving a background process
by choroba (Cardinal) on May 30, 2017 at 21:32 UTC | |
|
Re: Gtk2 app on Windows, driving a background process
by huck (Prior) on May 30, 2017 at 23:15 UTC | |
|
Re: Gtk2 app on Windows, driving a background process
by Marshall (Canon) on May 30, 2017 at 23:16 UTC | |
|
Re: Gtk2 app on Windows, driving a background process
by Anonymous Monk on May 30, 2017 at 23:11 UTC | |
|
Re: Gtk2 app on Windows, driving a background process
by zentara (Cardinal) on May 31, 2017 at 13:34 UTC | |
by Anonymous Monk on May 31, 2017 at 14:00 UTC | |
by syphilis (Archbishop) on Jun 01, 2017 at 00:42 UTC | |
by zentara (Cardinal) on Jun 01, 2017 at 16:31 UTC |