What is the correct way to force an app to core dump and quit?

前端 未结 5 1729
醉梦人生
醉梦人生 2021-01-12 19:19

I just came across some code which used the kill system call to send a SIGSEGV signal to an app. The rationale behind this was that this would force the app to core dump and

5条回答
  •  不思量自难忘°
    2021-01-12 19:44

    SIGQUIT is the correct signal to send to a program if you wish to produce a core dump. kill is the correct command line program to send signals (it is of course poorly named, since not all signals will kill the program).

    Note, you should not send random signals to the program, not all of them will produce a core dump. Many of them will be handled by the program itself, either consumed, ignored, or induce other processing. Thus sending a SIGSEGV is wrong.


    GCC Says: http://www.gnu.org/s/libc/manual/html_node/Termination-Signals.html

    POSIX/Unix Says: http://pubs.opengroup.org/onlinepubs/009695399/basedefs/signal.h.html

提交回复
热议问题