Which “fatal” signals should a user-level program catch?

前端 未结 3 737
情歌与酒
情歌与酒 2021-02-08 21:12

First of all, I do know that there was a similar question here in the past.

But that question wasn\'t answered properly. Instead, it diverted into suggestion what to do

3条回答
  •  野的像风
    2021-02-08 21:24

    I'm looking at my copy of advanced programming the unix environment (Stevens). According to the table in the section on signals, the following POSIX signals will by default terminate the process, if you don't catch them. It wouldn't be unreasonable to monitor all of these that you don't use:

    • SIGABRT
    • SIGALRM
    • SIGFPE
    • SIGHUP
    • SIGILL
    • SIGINT
    • SIGKILL
    • SIGPIPE
    • SIGQUIT
    • SIGSEGV
    • SIGTERM
    • SIGUSR1
    • SIGUSR2

    You can catch all of these except SIGKILL, but hopefully SIGKILL won't come up very often for you.

    Note that your signal man page (man 7 signal) should give you the proper list for your system - this is the POSIX list, and may differ depending on your architecture.

提交回复
热议问题