in reply to Re^3: Simple way to find on Windows, whether a process is running
in thread Simple way to find on Windows, whether a process is running

Upgrade. Works okay on AS 5.8.9
I'm not sure whether I'll get permission to upgrade (and in this case, I would go straight to 5.12 anyway).

Any suggestions how to solve it within 5.8.8?

-- 
Ronald Fischer <ynnor@mm.st>

Replies are listed 'Best First'.
Re^5: Simple way to find on Windows, whether a process is running
by BrowserUk (Patriarch) on Sep 12, 2011 at 10:02 UTC

    Attempt to use Win32::Process::Open( my $handle, $pid, 0 ); to obtain a handle to the running process. If the call succeeds, it is still running.

    You could also avoid having to poll the process by using $handle->Wait( $timeoutms ); to wait until it ends (or the timeout occurs) and then $handle->Kill( $exitcode ) to kill it if it runs too long.


    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.
Re^5: Simple way to find on Windows, whether a process is running
by Anonymous Monk on Sep 12, 2011 at 09:14 UTC
      An alternative to pslist would be wmic, which comes with Windows (at least from XP and up). However, I wanted to avoid a solution where I had to shell out for this, because it means that I need to filter out the PIDs for the pslist/wmic process (and, perhaps, an interim command shell process).

      I wanted to avoid Win32::Process::Info too, because of the many problems pointed out in its documentation, but after all, this was the solution I ended up with, because the alternatives were even less attractive.

      Actually, I personally would prefer upgrading Perl to a version where kill works as documented, but this is not feasible at the moment...
      -- 
      Ronald Fischer <ynnor@mm.st>