Register signal handler using sigaction() instead of signal()
This commit is contained in:
parent
7666e3a99a
commit
c200de7dc1
9
main.c
9
main.c
@ -107,16 +107,13 @@ int main(int argc, char *argv[])
|
||||
|
||||
/*
|
||||
* Register signal handler for SIGTERM and SIGINT.
|
||||
*
|
||||
* The behaviour of signal() is not entirely consistent across
|
||||
* different implementations, so this should ideally be rewritten
|
||||
* to use signaction() instead at some point.
|
||||
*/
|
||||
if (signal(SIGTERM, handle_exit_signal) == SIG_ERR) {
|
||||
const struct sigaction act = { .sa_handler = handle_exit_signal };
|
||||
if (sigaction(SIGTERM, &act, NULL) == -1) {
|
||||
fprintf(stderr, "Failed to register SIGTERM signal handler\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
if (signal(SIGINT, handle_exit_signal) == SIG_ERR) {
|
||||
if (sigaction(SIGINT, &act, NULL) == -1) {
|
||||
fprintf(stderr, "Failed to register SIGINT signal handler\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user