in reply to Piping output from child to parent Tk widget

In addition to what was said above about IPC, if you just want to print to STDOUT (and not actually have the processes talk to each other) you can use Parallel::ForkManager to spawn the child process, and have it call 'run_on_finish' which executes on the child process before it exits. That allows you to send a return code to the parent before the child dies (good for keep track of failures, etc) but still can print to STDOUT.

I guess I'm not exactly sure what your goal is. Either way, using Parallel::ForkManager does take a lot of complexity out of forking processes.
  • Comment on Re: Piping output from child to parent Tk widget

Replies are listed 'Best First'.
Re^2: Piping output from child to parent Tk widget
by Ohad (Novice) on Jul 01, 2010 at 13:51 UTC
    Hi,

    Really thanks for the quick response.

    I dont have a problem writing to STDOUT, the issue is writing to a text widget owned by the parent process.

    The process which creates the output doesnt ever stop, it's running on a loop, so using run_on_finish wouldnt help

    Thanks again for the reply.

      What is it that you want to write to the text widget? If it's something simple, a return code from the child process might suffice. Are you writing all of the ssh output to that widget?

      If it's not just a simple return value, it sounds like IPC (something like IPC::ShareLite) might be what you need. (I've never used it, but it seems pretty straightforward from what I've seen on the POD).

      Update: Misread part of your post, edited my response accordingly.