Home: Perl Programming Help: Win32 Programming Help:
Kill a process in Perl



uzers
Novice

Jul 10, 2009, 6:18 PM


Views: 6779
Kill a process in Perl

Hi Gurus!

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!

Uzers.


uzers
Novice

Jul 11, 2009, 3:19 AM


Views: 6774
Re: [uzers] Kill a process in Perl

Thanks PerlMonks! My problem was solved. Any one interested please see http://perlmonks.org/index.pl?node_id=779114!