diff options
author | Christian Hesse <mail@eworm.de> | 2024-06-18 22:09:01 +0200 |
---|---|---|
committer | Christian Hesse <mail@eworm.de> | 2024-06-18 22:09:01 +0200 |
commit | a07e7ec5d4e8477f731b12e1226d6775f5622f14 (patch) | |
tree | 9597bf0bbf492c0472e87112a30d0517a92a8b23 | |
parent | 861cf45760c602a5c55264309d86611ead7881f3 (diff) | |
download | mpd-notification-a07e7ec5d4e8477f731b12e1226d6775f5622f14.tar.gz mpd-notification-a07e7ec5d4e8477f731b12e1226d6775f5622f14.tar.zst |
use sigaction(2) instead of signal(2)
As stated in the man pages, `sigaction` should be preferred to `signal`.
-rw-r--r-- | mpd-notification.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/mpd-notification.c b/mpd-notification.c index ba5e63a..fb3d795 100644 --- a/mpd-notification.c +++ b/mpd-notification.c @@ -401,10 +401,13 @@ int main(int argc, char ** argv) { notify_notification_set_urgency(notification, NOTIFY_URGENCY_NORMAL); notify_notification_set_timeout(notification, notification_timeout * 1000); - signal(SIGHUP, received_signal); - signal(SIGINT, received_signal); - signal(SIGTERM, received_signal); - signal(SIGUSR1, received_signal); + struct sigaction act = { 0 }; + act.sa_handler = received_signal; + + sigaction(SIGHUP, &act, NULL); + sigaction(SIGINT, &act, NULL); + sigaction(SIGTERM, &act, NULL); + sigaction(SIGUSR1, &act, NULL); /* report ready to systemd */ #ifdef HAVE_SYSTEMD |