How can I check to see if a process is stopped from the command-line?
You can check whether the process is in stopped state, T
is ps
output.
You can do:
[ "$(ps -o state= -p PID)" = T ] && kill -CONT PID
[ "$(ps -o state= -p PID)" = T ]
tests whether the output ofps -o state= -p PID
isT
, if so sendSIGCONT
to the process. Replace PID with the actual process ID of the process.
Another way would be
pid=1
status=`cat /proc/$pid/wchan`
if [ "$status" == "do_signal_stop" ] ; then
echo "$pid sleeps: $status"
else
echo "$pid does not sleep: $status"
fi