【发布时间】:2014-02-11 03:18:55
【问题描述】:
我想检查我拥有的 pid 进程是否从内核扩展运行。
在用户空间中这很简单:
if (kill(pid, 0) == 0) {
printf("Process %d is running\n", pid);
} else if (errno == ESRCH) {
printf("Process %d is not running\n", pid);
} else {
printf("This shouldn't happen oO\n");
但不知何故 kill() 在内核中不可用。有没有其他方法可以做到这一点?
【问题讨论】:
-
在某种程度上是的,但我认为 Christophe 的回答和我的 sn-p 可能对其他用户有帮助
-
此问题将保持与副本的链接,因此如果问题作为副本关闭,人们可以看到您的答案和问题。如果它关闭了,请不要灰心。
标签: c linux process linux-kernel kernel