48
48
#include <error.h> /* error() */
49
49
#include <sysexits.h> /* EX_USAGE, EX_OSERR, EX_OSFILE */
50
50
#include <errno.h> /* errno, error_t, EACCES,
51
ENAMETOOLONG, ENOENT, ENOTDIR,
52
EEXIST, ECHILD, EPERM, ENOMEM,
53
EAGAIN, EINTR, ENOBUFS, EADDRINUSE,
51
ENAMETOOLONG, ENOENT, EEXIST,
52
ECHILD, EPERM, ENOMEM, EAGAIN,
53
EINTR, ENOBUFS, EADDRINUSE,
54
54
ECONNREFUSED, ECONNRESET,
55
55
ETOOMANYREFS, EMSGSIZE, EBADF,
83
83
#include <sys/mman.h> /* munlock(), mlock() */
84
84
#include <fcntl.h> /* O_CLOEXEC, O_NONBLOCK, fcntl(),
85
85
F_GETFD, F_GETFL, FD_CLOEXEC,
86
open(), O_WRONLY, O_NOCTTY,
87
O_RDONLY, O_NOFOLLOW */
86
open(), O_WRONLY, O_RDONLY */
88
87
#include <sys/wait.h> /* waitpid(), WNOHANG, WIFEXITED(),
90
89
#include <limits.h> /* PIPE_BUF, NAME_MAX, INT_MAX */
91
90
#include <sys/inotify.h> /* inotify_init1(), IN_NONBLOCK,
92
91
IN_CLOEXEC, inotify_add_watch(),
93
92
IN_CLOSE_WRITE, IN_MOVED_TO,
94
IN_MOVED_FROM, IN_DELETE,
95
IN_EXCL_UNLINK, IN_ONLYDIR,
96
struct inotify_event */
93
IN_DELETE, struct inotify_event */
97
94
#include <fnmatch.h> /* fnmatch(), FNM_FILE_NAME */
98
95
#include <stdio.h> /* asprintf(), FILE, fopen(),
99
96
getline(), sscanf(), feof(),
2229
2226
__attribute__((cleanup(cleanup_close)))
2230
const int devnull_fd = open("/dev/null",
2231
O_WRONLY | O_CLOEXEC | O_NOCTTY);
2227
const int devnull_fd = open("/dev/null", O_WRONLY | O_CLOEXEC);
2232
2228
g_assert_cmpint(devnull_fd, >=, 0);
2233
2229
__attribute__((cleanup(cleanup_close)))
2234
2230
const int real_stderr_fd = dup(STDERR_FILENO);
2259
2255
__attribute__((cleanup(cleanup_close)))
2260
2256
const int devnull_fd = open("/dev/null",
2261
O_WRONLY | O_CLOEXEC | O_NOCTTY);
2257
O_WRONLY | O_CLOEXEC);
2262
2258
g_assert_cmpint(devnull_fd, >=, 0);
2263
2259
__attribute__((cleanup(cleanup_close)))
2264
2260
const int real_stderr_fd = dup(STDERR_FILENO);
2910
2906
__attribute__((cleanup(cleanup_close)))
2911
2907
const int devnull_fd = open("/dev/null",
2912
O_WRONLY | O_CLOEXEC | O_NOCTTY);
2908
O_WRONLY | O_CLOEXEC);
2913
2909
g_assert_cmpint(devnull_fd, >=, 0);
2914
2910
__attribute__((cleanup(cleanup_close)))
2915
2911
const int real_stderr_fd = dup(STDERR_FILENO);
2981
2977
__attribute__((cleanup(cleanup_close)))
2982
2978
const int devnull_fd = open("/dev/null",
2983
O_WRONLY | O_CLOEXEC, O_NOCTTY);
2979
O_WRONLY | O_CLOEXEC);
2984
2980
g_assert_cmpint(devnull_fd, >=, 0);
2985
2981
__attribute__((cleanup(cleanup_close)))
2986
2982
const int real_stderr_fd = dup(STDERR_FILENO);
3024
3020
buffer password = {};
3026
3022
/* Reading /proc/self/mem from offset 0 will always give EIO */
3027
const int fd = open("/proc/self/mem",
3028
O_RDONLY | O_CLOEXEC | O_NOCTTY);
3023
const int fd = open("/proc/self/mem", O_RDONLY | O_CLOEXEC);
3030
3025
bool password_is_read = false;
3031
3026
bool quit_now = false;
3939
3934
const mono_microsecs current_time = 0;
3941
3936
/* Reading /proc/self/mem from offset 0 will always result in EIO */
3942
const int fd = open("/proc/self/mem",
3943
O_RDONLY | O_CLOEXEC | O_NOCTTY);
3937
const int fd = open("/proc/self/mem", O_RDONLY | O_CLOEXEC);
3945
3939
bool quit_now = false;
3946
3940
__attribute__((cleanup(cleanup_queue)))
5631
5625
__attribute__((unused))
5632
5626
gconstpointer user_data){
5633
5627
__attribute__((cleanup(cleanup_close)))
5634
const int epoll_fd = open("/dev/null",
5635
O_WRONLY | O_CLOEXEC | O_NOCTTY);
5628
const int epoll_fd = open("/dev/null", O_WRONLY | O_CLOEXEC);
5636
5629
__attribute__((cleanup(cleanup_string)))
5637
5630
char *const question_filename = strdup("/nonexistent/question");
5638
5631
g_assert_nonnull(question_filename);
6042
6035
__attribute__((unused))
6043
6036
gconstpointer user_data){
6044
6037
__attribute__((cleanup(cleanup_close)))
6045
const int epoll_fd = open("/dev/null",
6046
O_WRONLY | O_CLOEXEC | O_NOCTTY);
6038
const int epoll_fd = open("/dev/null", O_WRONLY | O_CLOEXEC);
6047
6039
__attribute__((cleanup(cleanup_string)))
6048
6040
char *const question_filename = strdup("/nonexistent/question");
6049
6041
g_assert_nonnull(question_filename);
6312
6304
const char *const
6314
6306
__attribute__((cleanup(cleanup_close)))
6315
const int devnull_fd = open("/dev/null",
6316
O_WRONLY | O_CLOEXEC | O_NOCTTY);
6307
const int devnull_fd = open("/dev/null", O_WRONLY | O_CLOEXEC);
6317
6308
g_assert_cmpint(devnull_fd, >=, 0);
6318
6309
__attribute__((cleanup(cleanup_close)))
6319
6310
const int real_stderr_fd = dup(STDERR_FILENO);