All system() does is run the command you give it to the command line. Running the command "ps -A" on the command line will give you the PID of every process running on the computer. So you could either kill the PID you find, or get lazy and do killall (name of the process) to kill any processes close to that processes name. If this bothers Perl, do killall perl for good measure.
In perl how to kill a process started by system(), How do I get PID of the process ?
When you run a command with system() in perl, the system() call doesn't return until the process is done, so there is no way to get the PID.
If you want to run a command while your program is running, you need to do a fork() and an exec(). The fork() call returns the PID of the child process. See the bottom source for an example of how to do this.
To kill a process, use the kill() command ( http://perldoc.perl.org/functions/kill.h... )
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment