in reply to Win32::Job::watch vs. system(1,...)

Did I miss something here?

Yes. Someone has to watch, system 1... never watched, unless you spawned, I mean system 1... a watcher program.

  • Comment on Re: Win32::Job::watch vs. system(1,...)

Replies are listed 'Best First'.
Re^2: Win32::Job::watch vs. system(1,...)
by rovf (Priest) on Sep 25, 2009 at 07:34 UTC
    Someone has to watch, system 1... never watched
    With system 1, I can implement the watching by myself. My main focus was not so much, how to implement the "watch" logic, but to find an easy way to create a separate process (or thread), which can later be killed in a way that killing the process would automatically kill its childs. My first approach was to use system 1 for creating the process, and then remembering the PID, and later using kill -9 to kill this process.

    When discussing this solution, BrowserUk suggested using Win32::Job instead. I was only vaguely famimilar with this module and new that I can use it to control a process in a way that I can kill a whole process tree (the childs of the process) easily, so I thought that maybe there is also some feature in Win32::Job which would do the spawning. It seems that I was wrong with this. Or I stay with my original solution of sticking with system 1 only and kill the process with -9 (negative kill signal also means to kill the process group, but I have yet to find out whether this really always works reliably on Windows).

    So the safest way would probably be to spawn a separate process (using system 1, and within this process use Win32::Job to spawn my application and control it using watch.
    -- 
    Ronald Fischer <ynnor@mm.st>