1
1
#define _GNU_SOURCE /* asprintf() */
2
2
#include <signal.h> /* sig_atomic_t, struct sigaction,
3
sigemptyset(), sigaddset(),
4
sigaction, SIGINT, SIG_IGN, SIGHUP,
5
SIGTERM, kill(), SIGKILL */
3
sigemptyset(), sigaddset(), SIGINT,
4
SIGHUP, SIGTERM, sigaction(),
5
SIG_IGN, kill(), SIGKILL */
6
#include <stdbool.h> /* bool, false, true */
7
#include <fcntl.h> /* open(), O_WRONLY, O_RDONLY */
8
#include <errno.h> /* errno, EINTR */
9
#include <sys/types.h> /* size_t, ssize_t, pid_t, DIR,
6
11
#include <stddef.h> /* NULL */
12
#include <string.h> /* strlen(), memcmp() */
13
#include <stdio.h> /* asprintf(), perror() */
14
#include <unistd.h> /* close(), write(), readlink(),
15
read(), STDOUT_FILENO, sleep(),
16
fork(), setuid(), geteuid(),
17
setsid(), chdir(), dup2(),
18
STDERR_FILENO, execv() */
19
#include <stdlib.h> /* free(), EXIT_FAILURE, strtoul(),
20
realloc(), EXIT_SUCCESS, malloc(),
7
22
#include <stdlib.h> /* getenv() */
8
#include <stdio.h> /* asprintf(), perror() */
9
#include <stdlib.h> /* EXIT_FAILURE, EXIT_SUCCESS,
11
#include <sys/types.h> /* pid_t, DIR, struct dirent,
13
23
#include <dirent.h> /* opendir(), readdir(), closedir() */
14
#include <unistd.h> /* readlink(), fork(), execl(),
16
#include <string.h> /* memcmp() */
17
27
#include <iso646.h> /* and */
18
#include <stdbool.h> /* bool, false, true */
19
#include <errno.h> /* errno */
20
28
#include <sys/wait.h> /* waitpid(), WIFEXITED(),
22
#include <fcntl.h> /* open(), O_RDONLY */
24
31
sig_atomic_t interrupted_by_signal = 0;