Run a process but on a certain pid

Hi all,

I am having a little bit of trouble trying to find something out. I am trying to script a start/stop php file, for some gaming servers i host. The server have 2 lots of processes running on them, and the customers need to be able to start and stop them at their will.

So i know how to run a .sh file using php:

system('sh run.sh');

But because i can only kill by pid (kill -9 pid), i need to know if its possible to run the sh files on a certain pid, and if not how to find the correct pid on the process which has been run.

Thanks in advance.

You won't have anything to kill, as system() only returns when the command is finished. If you want to send a signal to a command started by the script, you'll have to do so from within the script, and pass the PID back to PHP (or whatever other program) through a file.

Side note: sending SIGKILL should be the last resort. Try sending SIGTERM (15) first.