in reply to Give me my gui back!
Essentially, when you fork off the child, open a pipe to read from it (bi-directional would be harder, but still possible). Here's the basic idea:
Then, in your main-loop, do a non-blocking read from KID_TO_READ. (There are plenty of good examples around here of how to use IO::Select for non-blocking reads.) Anyway, you take that non-blocking read as an additional source of incoming events into your main loop. That way, you can be kept constantly abrest of the status of the executing job.$pid = open(KID_TO_READ, "-|"); die "Unable to fork: $!\n" unless defined $pid; if (!$pid) { # child exec($program, @options, @args) or die "Can't exec $program: $!\n"; }
Also, since you've got the pid of the executing job, you can tie a button in your GUI to send a signal (like INT to stop, etc) to your job.
|
|---|