Jul 10, 2009, 6:18 PM
Post #1 of 2
Kill a process in Perl
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 take 10mins ?
I must kill it by it's process ID but not the process name, because it is supposed I will run many a.exe at the same time, and I only want the perl to kill its own a.exe.
I think I need to use "sleep()" and "fork()", but still have no clear idea how to write the whole code after searching over the internet, perhaps my level is too low understand them.
I would be very much appreciated if you can write some sample code. Thank you very much!