How can I timeout a forked process that might hang?

后端 未结 4 554
走了就别回头了
走了就别回头了 2021-02-09 08:36

I am writing a Perl script that will write some inputs and send those inputs to an external program. There is a small but non-zero chance that this program will hang, and I want

4条回答
  •  悲&欢浪女
    2021-02-09 09:07

    The only way SIGKILL can be ignored is if the process is stuck in a system call which is uninterruptible. Check the state of the hung process (with ps aux) if the state is D, then the process can't be killed.

    You might also want to check that the function is being called by outputting something from it.

提交回复
热议问题