From a07e7ec5d4e8477f731b12e1226d6775f5622f14 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 18 Jun 2024 22:09:01 +0200 Subject: use sigaction(2) instead of signal(2) As stated in the man pages, `sigaction` should be preferred to `signal`. --- mpd-notification.c | 11 +++++++---- 1 file 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 -- cgit v1.2.3-70-g09d2