mirror of
https://github.com/vale981/bspwm
synced 2025-03-06 10:11:43 -05:00
Handle SIG{INT,HUP,TERM} signals
This commit is contained in:
parent
86940387b3
commit
ad5d5a9390
1 changed files with 8 additions and 2 deletions
10
bspwm.c
10
bspwm.c
|
@ -116,6 +116,9 @@ int main(int argc, char *argv[])
|
|||
if (listen(sock_fd, SOMAXCONN) == -1)
|
||||
err("Couldn't listen to the socket.\n");
|
||||
|
||||
signal(SIGINT, sig_handler);
|
||||
signal(SIGHUP, sig_handler);
|
||||
signal(SIGTERM, sig_handler);
|
||||
signal(SIGCHLD, sig_handler);
|
||||
signal(SIGPIPE, SIG_IGN);
|
||||
load_settings();
|
||||
|
@ -343,8 +346,11 @@ void put_status(void)
|
|||
|
||||
void sig_handler(int sig)
|
||||
{
|
||||
signal(sig, sig_handler);
|
||||
if (sig == SIGCHLD)
|
||||
if (sig == SIGCHLD) {
|
||||
signal(sig, sig_handler);
|
||||
while (waitpid(-1, 0, WNOHANG) > 0)
|
||||
;
|
||||
} else if (sig == SIGINT || sig == SIGHUP || sig == SIGTERM) {
|
||||
running = false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue