23
23
 * Contact the authors at <mandos@recompile.se>.
 
26
 
#define _GNU_SOURCE             /* asprintf(), TEMP_FAILURE_RETRY() */
 
27
 
#include <signal.h>             /* sig_atomic_t, struct sigaction,
 
28
 
                                   sigemptyset(), sigaddset(), SIGINT,
 
29
 
                                   SIGHUP, SIGTERM, sigaction(),
 
30
 
                                   SIG_IGN, kill(), SIGKILL */
 
 
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, ENOENT, EINTR */
 
 
36
#include <string.h>             /* strerror(), strlen(), memcmp() */
 
 
37
#include <error.h>              /* error() */
 
 
38
#include <stdlib.h>             /* free(), getenv(), realloc(),
 
 
39
                                   EXIT_FAILURE, EXIT_SUCCESS,
 
31
41
#include <stdbool.h>            /* bool, false, true */
 
32
42
#include <fcntl.h>              /* open(), O_WRONLY, O_RDONLY */
 
33
 
#include <iso646.h>             /* and, or, not*/
 
34
 
#include <errno.h>              /* errno, EINTR */
 
36
 
#include <sys/types.h>          /* size_t, ssize_t, pid_t, DIR, struct
 
38
 
#include <stddef.h>             /* NULL */
 
39
 
#include <string.h>             /* strlen(), memcmp(), strerror() */
 
40
 
#include <stdio.h>              /* asprintf(), vasprintf(), vprintf(),
 
42
 
#include <unistd.h>             /* close(), write(), readlink(),
 
43
 
                                   read(), STDOUT_FILENO, sleep(),
 
44
 
                                   fork(), setuid(), geteuid(),
 
45
 
                                   setsid(), chdir(), dup2(),
 
46
 
                                   STDERR_FILENO, execv() */
 
47
 
#include <stdlib.h>             /* free(), EXIT_FAILURE, realloc(),
 
48
 
                                   EXIT_SUCCESS, malloc(), _exit(),
 
50
 
#include <dirent.h>             /* opendir(), readdir(), closedir() */
 
 
43
#include <stddef.h>             /* size_t, NULL */
 
 
44
#include <unistd.h>             /* close(), ssize_t, write(),
 
 
45
                                   readlink(), read(), STDOUT_FILENO,
 
 
46
                                   sleep(), fork(), setuid(),
 
 
47
                                   geteuid(), setsid(), chdir(),
 
 
48
                                   _exit(), dup2(), STDERR_FILENO,
 
 
49
                                   execv(), TEMP_FAILURE_RETRY(),
 
 
51
#include <dirent.h>             /* DIR, opendir(), struct dirent,
 
 
52
                                   readdir(), closedir() */
 
51
53
#include <inttypes.h>           /* intmax_t, strtoimax() */
 
52
 
#include <sys/stat.h>           /* struct stat, lstat(), S_ISLNK */
 
 
54
#include <iso646.h>             /* or, not, and */
 
 
55
#include <sys/stat.h>           /* struct stat, lstat(), S_ISLNK() */
 
53
56
#include <sysexits.h>           /* EX_OSERR, EX_UNAVAILABLE */
 
 
57
#include <signal.h>             /* struct sigaction, sigemptyset(),
 
 
58
                                   sigaddset(), SIGINT, SIGHUP,
 
 
59
                                   SIGTERM, SIG_IGN, kill(), SIGKILL,
 
54
61
#include <argz.h>               /* argz_count(), argz_extract() */
 
55
 
#include <stdarg.h>             /* va_list, va_start(), ... */
 
57
63
sig_atomic_t interrupted_by_signal = 0;
 
58
64
int signal_received;