in reply to Win32 Processes...capturing output and timing out

You may want to
use threads;
use threads::shared;

Start your external process within a thread, (no need for "exec", then pass data to the parent using shared variables or
use Thread::Queue;

The parent process can manage the threads, timing them out, and killing as required.

     "There are only two truly infinite things. The universe and stupidity, and I'm not too sure about the universe"- Albert Einstein

  • Comment on Re: Win32 Processes...capturing output and timing out

Replies are listed 'Best First'.
Re^2: Win32 Processes...capturing output and timing out
by keydet89 (Initiate) on Apr 21, 2005 at 17:58 UTC
    NetWallah,

    Thanks for the response...I'm looking into it now.

    One thing I'm grappling with is this...I can ignore a thread, or wait for it to exit...but how do I say, wait for x seconds, and if the thread hasn't completed, kill it?

    Thanks again for your help.

      You might find this subthread useful, but do read the whole subthread.


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      Lingua non convalesco, consenesco et abolesco.
      Rule 1 has a caveat! -- Who broke the cabal?
      No clean way that I know of, to kill a thread.

      Here is a link to some PM discussion of a usable, but ugly option.

           "There are only two truly infinite things. The universe and stupidity, and I'm not too sure about the universe"- Albert Einstein

        All,

        I came up with a solution...not the prettiest, but it works.

        First, create a wrapper for launching executables, using Win32::Job. Use Win32::Job's run() function to implement the timeout. Launch this wrapper from the main application, which captures the output.

        The use of Win32::Job limits this to the Win2K+ platforms...but for now, that's not really a big issue.

        Thanks!