diff options
author | Daniel Friesel <derf@finalrewind.org> | 2017-09-16 01:32:57 +0200 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2017-09-16 01:32:57 +0200 |
commit | e91a10ecb2e1f7c237e77e47936932ce14fbec32 (patch) | |
tree | 97492e733aef58f0fee0d5b7e029d4046ad70850 /src/wallpaper.c | |
parent | 820838242134f6bc2078610a6498a62722bca239 (diff) |
Replace legacy signal(...) call with sigaction(...)
Diffstat (limited to 'src/wallpaper.c')
-rw-r--r-- | src/wallpaper.c | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/src/wallpaper.c b/src/wallpaper.c index 2f7810f..f40c613 100644 --- a/src/wallpaper.c +++ b/src/wallpaper.c @@ -779,10 +779,11 @@ void enl_ipc_send(char *str) return; } -static sighandler_t *enl_ipc_timeout(int sig) +void enl_ipc_timeout(int sig) { - timeout = 1; - return((sighandler_t *) sig); + if (sig == SIGALRM) + timeout = 1; + return; } char *enl_wait_for_reply(void) @@ -842,7 +843,8 @@ char *enl_ipc_get(const char *msg_data) char *enl_send_and_wait(char *msg) { char *reply = IPC_TIMEOUT; - sighandler_t old_alrm; + struct sigaction e17_sh, feh_sh; + sigset_t e17_ss; /* * Shortcut this func and return IPC_FAKE @@ -861,7 +863,19 @@ char *enl_send_and_wait(char *msg) sleep(1); } } - old_alrm = (sighandler_t) signal(SIGALRM, (sighandler_t) enl_ipc_timeout); + + if ((sigemptyset(&e17_ss) == -1) || sigaddset(&e17_ss, SIGALRM) == -1) { + weprintf("Failed to set up temporary E17 signal masks"); + return reply; + } + e17_sh.sa_handler = enl_ipc_timeout; + e17_sh.sa_mask = e17_ss; + e17_sh.sa_flags = 0; + if (sigaction(SIGALRM, &e17_sh, &feh_sh) == -1) { + weprintf("Failed to set up temporary E17 signal handler"); + return reply; + } + for (; reply == IPC_TIMEOUT;) { timeout = 0; enl_ipc_send(msg); @@ -873,6 +887,8 @@ char *enl_send_and_wait(char *msg) ipc_win = None; } } - signal(SIGALRM, old_alrm); + if (sigaction(SIGALRM, &feh_sh, NULL) == -1) { + weprintf("Failed to restore signal handler"); + } return(reply); } |