I have the pid and I just stopped a program using
kill -stop PID
Now I want to continue it by doing
kill -cont PID
But only if it's already stopped. How would I check to see if it's stopped or running?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
You can check whether the process is in stopped state,
You can do:
[ "$(ps -o state= -p PID)" = T ] && kill -CONT PID
[ "$(ps -o state= -p PID)" = T ]tests whether the output of
ps -o state= -p PIDis
T, if so send
SIGCONTto the process. Replace PID with the actual process ID of the process.