简体   繁体   中英

How to see if a process is suspended in unix

I'm trying to resume all processes that are suspended ,but i have no idea how to check if a process is suspended. I tried but it dose not indicate if the process is suspended or running.

You might use Ipor's way ( /proc/<pid>/status ) if you are using Linux but a more portable solution that should work with most Unix/Unix likes OSes would be to use a standard command as Barmar already suggested in a comment:

ps -o s= -p <pid>

This will show T for a suspended process (also if stopped because being debugged).

Examining process with pid $pid is easy:

if grep -q "^State.*stopped" /proc/$pid/status; then
    echo Process $pid is sleeping
else
    echo Process $pid is active
fi

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM