开发者

Time to stop a Linux process using SIGSTOP

I am stopping a shell script from running, from another C program. Code below: kill(pid, SIGSTOP); I wanted to know is there any kernel related delay for that shell script to get stopped.

In other words what is the worst case for SIGSTOP to stop another process? Is there any similar delay for SIGCONT 开发者_Go百科?


kill is asynchronous. That means the time it takes is unbounded in general. If the system is heavily loaded, for example, it will take longer. There is no bound that will work 100% of the time, even if the target process is otherwise idle.

You must design your applications such that kill can take arbitrarily long; you must not care how long it takes. If you provide more details about why you do care, someone can probably give you suggestions for how to fix that.


The worst case for SIGSTOP is infinite (where infinite is until system shutdown) in the case of processes that get stuck in uninterruptible sleep - typically waiting on io that will never complete because something physically broke or something crashed in kernel space.

The best case depends on system load and possibly number of cpus even though SIGSTOP is handled entirely in kernel space unlike most other signals. All signals are asynchronous and unbounded, but SIGSTOP has the lowest latency of all signals for a given process even though it may still be infinite :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜