gpt4 book ai didi

c++ - 判断进程是否挂起

转载 作者:搜寻专家 更新时间:2023-10-31 00:16:41 25 4
gpt4 key购买 nike

我尝试向特定进程发送 SIGTSTP 信号,但如何使用 Linux 中的 C 库函数或系统调用来确定该进程是否实际上已挂起?

最佳答案

/proc/[pid]/stat 中读取。

来自man page ,您可以从此文件中获取进程的状态:

state %c

One character from the string "RSDZTW" where R is running, S is sleeping in an interruptible wait, D is waiting in uninterruptible disk sleep, Z is zombie, T is traced or stopped (on a signal), and W is paging.

关于c++ - 判断进程是否挂起,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15330889/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com