前端之家收集整理的这篇文章主要介绍了
检查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