超时后将SIGTERM升级为SIGKILL

问题描述

我想将SIGTERM发送到一个进程,然后在10秒内没有停止时升级SIGKILL。有什么方法可以让我不必忙于等待吗?下面是我的代码的概述。

printf("Sending sigterm\n");
kill(ret,SIGTERM);

// Run this while loop for 10 seconds or wait for process to be killed?
while (kill(ret,0) == 0)
{
}

// If the process is still running 10 seconds after sending SIGTERM,must kill
if (kill(ret,0) == 0)
{
    kill(ret,SIGKILL);
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)