in reply to Re: Killing a process on Windows (Win32::Process question)
in thread Killing a process on Windows (Win32::Process question)

The problem is that the creation of subprocesses happens outside my Perl application. I basically get as input a string, which contains some Windows command (typically the name of a Batch file). I then need to create a job (I create a console for this), and this is the job which I want to kill when it runs for too long. The problem is that I have no idea what the batch file will be doing. It can call some EXE file which in turn creates tons of subprocesses. If I understand you right, Win32::Job won't help me in this case.

-- 
Ronald Fischer <ynnor@mm.st>

Replies are listed 'Best First'.
Re^3: Killing a process on Windows (Win32::Process question)
by BrowserUk (Patriarch) on May 14, 2009 at 14:13 UTC
    If I understand you right, Win32::Job won't help me in this case.

    Actually, it probably will. According to the docs:

    By default, processes created using CreateProcess by a process associated with a job are associated with the job;

    Which mean if you create a job (a Win32::Job), and then associate the top level process you start with that job, then any processes it spawns will also be associated with that job. You should then be able to kill them all by killing the job.


    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.

      Thanks a lot!!! I will try this alternative!

      -- 
      Ronald Fischer <ynnor@mm.st>