So I had some PHP scripts running from the command line, and wanted to stop them running.
I ran
$ ps aux | grep php
$ sudo kill 8754
$ sudo kill 8767
And then ran
$ ps aux | grep php
again to check the processes had terminated but got this kind of output:
jon 8754 0.4 53.5 3044256 2205204 ? T 10:34 0:15 php awesome_script.php
jon 8767 0.4 53.5 3044256 2205204 ? T 10:34 0:15 php awesome_script.php
jon 12275 0.0 0.0 4156 892 pts/1 S+ 11:27 0:00 grep --color=auto php
I looked up what the T meant in the state column and discovered that it means Stopped, but I don't understand what that means the process is doing.
I know you can create your own signal handling in PHP, but I've not done that, so when PHP receives a SIGTERM signal what does it do?
What is a stopped process doing (if anything)?
Best Answer
It means the process has received a
STOP
signal, and won't do anything much until it receives aCONT
signal, not even terminate.The most common source of
STOP
signals is the user hitting^z
while the process is in the foreground, and the common way to send aCONT
afterwards is typingfg
orbg
which continue the process in the foreground and background respectively.Another way to send
STOP
to a process iskill -STOP $pid
. Similarly,CONT
can be sent to a process withkill -CONT $pid
.Since you sent
TERM
signals to the processes, I assume you want them to terminate. For that to happen, the processes must receiveCONT
signals. You can send those by typingkill -CONT 8754 8767
in a terminal window.