Kill a process in Perl

Discussion in 'Perl' started by uzers, Jul 11, 2009.

  1. uzers

    uzers New Member

    Joined:
    Jul 11, 2009
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Hi Experts,

    I am trying to kill an external process called out in Perl after certain seconds.

    I am using Windows.

    For example, I called out "a.exe" in perl by

    my $result = `a.exe`;

    What should I do to kill the "a.exe" after 30 seconds before a.exe naturally ends by itself which usually takes 10mins ?

    I must kill it by it's process ID but not the process name, because I will run many a.exe at the same time, and I only want the perl to kill its own a.exe. But, I have no idea how to get process ID...

    Please help me. Thanks in advance!

    Uzers.
     
  2. uzers

    uzers New Member

    Joined:
    Jul 11, 2009
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Thanks PerlMonks! My problem was solved. Use Win32::Process (Create and Kill). No need to use fork even.

    Uzers.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice