Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linux Command to Show Stopped and Running processes?

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);
like image 316
Vimzy Avatar asked Sep 30 '15 06:09

Vimzy


1 Answers

jobs -s list stopped process by SIGTSTP, no SIGSTOP. The main difference is that SIGSTOP cannot be ignored. More info with help jobs.

You can SIGTSTP a process with ^Z or from other shell with kill -TSTP PROC_PID (or with pkill, see below), and then list them with jobs.

But what about list PIDs who had received SIGSTOP? One way to get this is

 ps -e -o stat,command,pid | grep '^T '

From man ps:

T stopped by job control signal


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 pkill or killall:

pkill -STOP procName
pkill -CONT procName
like image 150
Pablo Bianchi Avatar answered Sep 30 '22 08:09

Pablo Bianchi