23
23
* Contact the authors at <mandos@recompile.se>.
26
#define _GNU_SOURCE /* TEMP_FAILURE_RETRY(), asprintf() */
27
#include <signal.h> /* sig_atomic_t, struct sigaction,
28
sigemptyset(), sigaddset(), SIGINT,
29
SIGHUP, SIGTERM, sigaction,
30
SIG_IGN, kill(), SIGKILL */
31
#include <stddef.h> /* NULL */
32
#include <stdlib.h> /* getenv() */
33
#include <stdio.h> /* asprintf(), vasprintf(), vprintf(),
35
#include <stdlib.h> /* EXIT_FAILURE, free(),
37
#include <sys/types.h> /* pid_t, DIR, struct dirent,
39
#include <dirent.h> /* opendir(), readdir(), closedir() */
40
#include <inttypes.h> /* intmax_t, strtoimax() */
41
#include <sys/stat.h> /* struct stat, lstat(), S_ISLNK */
42
#include <iso646.h> /* not, or, and */
43
#include <unistd.h> /* readlink(), fork(), execl(),
44
sleep(), dup2() STDERR_FILENO,
45
STDOUT_FILENO, _exit(),
47
#include <string.h> /* memcmp(), strerror() */
48
#include <errno.h> /* errno, EACCES, ENOTDIR, ELOOP,
26
#define _GNU_SOURCE /* vasprintf(),
27
program_invocation_short_name,
28
asprintf(), TEMP_FAILURE_RETRY() */
29
#include <sys/types.h> /* sig_atomic_t, pid_t, setuid(),
30
geteuid(), setsid() */
31
#include <stdarg.h> /* va_list, va_start(), vfprintf() */
32
#include <stdio.h> /* vasprintf(), fprintf(), stderr,
33
vfprintf(), asprintf() */
34
#include <errno.h> /* program_invocation_short_name,
35
errno, EACCES, ENOTDIR, ELOOP,
49
36
ENOENT, ENAMETOOLONG, EMFILE,
50
37
ENFILE, ENOMEM, ENOEXEC, EINVAL,
51
38
E2BIG, EFAULT, EIO, ETXTBSY,
52
39
EISDIR, ELIBBAD, EPERM, EINTR,
41
#include <string.h> /* strerror(), memcmp() */
54
42
#include <error.h> /* error() */
43
#include <stdlib.h> /* free(), EXIT_FAILURE, getenv(),
44
EXIT_SUCCESS, abort() */
45
#include <stddef.h> /* NULL */
46
#include <dirent.h> /* DIR, opendir(), struct dirent,
47
readdir(), closedir() */
48
#include <sysexits.h> /* EX_OSERR, EX_OSFILE,
50
#include <inttypes.h> /* intmax_t, strtoimax() */
51
#include <iso646.h> /* or, not, and */
52
#include <unistd.h> /* ssize_t, readlink(), fork(),
54
TEMP_FAILURE_RETRY(), sleep(),
55
setuid(), geteuid(), setsid(),
56
chdir(), dup2(), STDERR_FILENO,
57
STDOUT_FILENO, pause() */
58
#include <sys/stat.h> /* struct stat, lstat(), S_ISLNK() */
59
#include <signal.h> /* struct sigaction, sigemptyset(),
60
sigaddset(), SIGINT, SIGHUP,
61
SIGTERM, SIG_IGN, kill(), SIGKILL,
55
63
#include <sys/wait.h> /* waitpid(), WIFEXITED(),
57
#include <sysexits.h> /* EX_OSERR, EX_OSFILE,
59
#include <stdarg.h> /* va_list, va_start(), ... */
61
66
sig_atomic_t interrupted_by_signal = 0;
62
67
int signal_received;