mirror of
https://github.com/javalsai/lidm.git
synced 2026-07-15 07:24:18 +02:00
7e7a297e2e
Co-authored-by: grialion <48643945+grialion@users.noreply.github.com>
30 lines
499 B
C
30 lines
499 B
C
#include <errno.h>
|
|
#include <stddef.h>
|
|
#include <sys/wait.h>
|
|
#include <unistd.h>
|
|
|
|
#include "signal_handler.h"
|
|
|
|
static void handle_sigterm(int sig) {
|
|
(void)sig;
|
|
|
|
(void)signal(SIGTERM, SIG_IGN);
|
|
kill(-getpgrp(), SIGTERM);
|
|
|
|
int status;
|
|
while (waitpid(-1, &status, 0) > 0 || errno == EINTR) {
|
|
}
|
|
|
|
_exit(0);
|
|
}
|
|
|
|
void setup_sigterm() {
|
|
setpgid(0, 0);
|
|
|
|
struct sigaction sa;
|
|
sa.sa_handler = handle_sigterm;
|
|
sigemptyset(&sa.sa_mask);
|
|
sa.sa_flags = 0;
|
|
sigaction(SIGTERM, &sa, NULL);
|
|
}
|