in reply to kill a process with process name
Don't use fork on Windows. Windows emulates fork using a thread. Therefore, exec cannot replace the "child process" with the program exec'd. Therefore the "$pid" for the child does not refer to that exec'd process, but rather is actually a thread handle. So killing that "$pid", only kills the thread, and not the exec'd program.
A far simpler mechanism of running an asynchronous process on windows is to use system with a first parameter of '1'. It will the return the pid of the program started and kill will act on it directly:
perl -wle"my $pid= system 1,'c:/windows/system32/calc.exe';sleep 3;kil +l 9,$pid"
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: kill a process with process name
by Anonymous Monk on Apr 14, 2010 at 12:37 UTC | |
by BrowserUk (Patriarch) on Apr 14, 2010 at 14:12 UTC | |
by Anonymous Monk on Apr 16, 2010 at 08:44 UTC | |
by BrowserUk (Patriarch) on Apr 16, 2010 at 15:18 UTC |