I'm presently executing the following Linux command in one of my c programs to display processes that are running. Is there anyway I can modify it to show stopped processes and running ones?
char *const parmList[] = {"ps","-o","pid,ppid,time","-g","-r",groupProcessID,NULL};
execvp("/bin/ps", parmList);
jobs -s
list stopped process by SIGTSTP,
no SIGSTOP
. The main difference is that SIGSTOP
cannot be ignored.
You can SIGTSTP
a process with ^Z
or from other shell with kill -TSTP PROC_PID
, and then list with jobs
.
But what about listing PIDs who had received SIGSTOP? One way to get this is
ps -e -o stat,command,pid | grep '^S '
I found very useful this two to stop/cont for a while some process (usually the browser):
kill -STOP $(pgrep procName)
kill -CONT $(pgrep procName)
Or with killall
killall -STOP procName
killall -CONT procName