|There's more than one way to do things|
Re: Read STDOUT from Win32::Job while process is runningby BrowserUk (Pope)
|on Mar 08, 2012 at 19:23 UTC||Need Help??|
Win32::Job is fine when you don't need to do anything with the processes it spawns for you, but it limited otherwise.
This example starts a perl one-liner that in turn start the windows calculator and notepad. 10 seconds after the jobs are started, they will disappear. The final sleep is there to show you that the closeHandle() worked:
You call createJobObject() with a name to get a job handle; assignProcessToJobObject(), with that job handle and the pid for each process you want added to the job; and call closeHandle( $job ) when you want the job to terminate all the processes it includes.
You can also use kill on the process(es) you started and all their children will also die.
However, if you allow your script to end without killing the kids or closing the job handle, you process will block until the kids go away of their own accord.
That could probably be worked up into a module if there was any demand for it.
With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.