Externally disabling signals for a Linux program

前端 未结 5 2054
慢半拍i
慢半拍i 2021-02-13 13:00

On Linux, is it possible to somehow disable signaling for programs externally... that is, without modifying their source code?

Context:

5条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-13 14:00

    The solutions explained above are not working for me, even by chaining the both commands proposed by Caf.

    However, I finally succeeded in getting the expected behavior this way :

    #!/bin/zsh
    setopt MONITOR
    TRAPINT() { print AAA }
    
    print 1
    ( ./child & ; wait)
    print 2
    

    If I press Ctrl-C while child is running, it will wait that it exits, then will print AAA and 2. child will not receive any signals.

    The subshell is used to prevent the PID from being shown.

    And sorry... this is for zsh though the question is for bash, but I do not know bash enough to provide an equivalent script.

提交回复
热议问题