Externally disabling signals for a Linux program

前端 未结 5 2055
慢半拍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 13:55

    The "trap" command is local to this process, never applies to children.

    To really trap the signal, you have to hack it using a LD_PRELOAD hook. This is non-trival task (you have to compile a loadable with _init(), sigaction() inside), so I won't include the full code here. You can find an example for SIGSEGV on Phack Volume 0x0b, Issue 0x3a, Phile #0x03.

    Alternativlly, try the nohup and tail trick.

    nohup  your_command &
    tail -F nohup.out
    

提交回复
热议问题