检查C中的运行进程

前端之家收集整理的这篇文章主要介绍了检查C中的运行进程前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
有人可以告诉我如何检查一个具有给定进程ID的unix进程是否在C程序中运行.我知道我可以调用system()并使用ps命令,但是我不想调用system().

@R_301_323@

使用 kill(2)
if (kill(pid,0) == 0) {
    /* process is running or a zombie */
} else if (errno == ESRCH) {
    /* no such process with the given pid is running */
} else {
    /* some other error... use perror("...") or strerror(errno) to report */
}
原文链接:https://www.f2er.com/c/114321.html

猜你在找的C&C++相关文章