A program I am working on uses a control panel setup for operation. Everything is done with buttons in a form. When the main portion of the program is executed, it forks off and operates in the background. You can monitor its progress by viewing a log file it creates as it goes.
Now, the background process can take anywhere from a handful of seconds to quite a few minutes to complete. I want add a way for users to kill the background process if they need to. Currently, I have the process write it's PID to a file (which doubles as a lock to prevent multiple instances of the program from being run at the same time). So, when a user wants to stop the process, the control panel portion of the script can get the PID out of the file and kill it. The problem is, I want to be able to get the process name of PID xxx so I can have the script check and be sure that pid xxx is what it should be. I don't want to have someone click the "kill" button a week after the script has stopped and kill some other process that just happens to share the same number (of course, the script deletes the lock/PID file when it finishes so this shouldn't happen, but just in case...). I want to do this using PERL functions, if possible. I don't want to make system calls to ps or anything like that if I can avoid it, but that's what my searches keep turning up.
I know that there are a lot of factors conspiring against me accidentally killing off the wrong process, but I suffer from paranoia. I don't like to leave anything to chance. I'd appreciate it if someone can point me in the right direction.
Thanks,
SpaceAce
In reply to Killing wayward children by SpaceAce
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |