Make sure pipes are closed on exec.

This commit is contained in:
Adam Harrison
2022-04-26 12:14:38 -04:00
committed by jgmdev
parent 4bf4851736
commit 9f7c6974ae
+3
View File
@@ -2,6 +2,7 @@
#include <sys/select.h> #include <sys/select.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <fcntl.h>
struct dirmonitor_internal { struct dirmonitor_internal {
@@ -15,6 +16,8 @@ struct dirmonitor_internal* init_dirmonitor() {
struct dirmonitor_internal* monitor = calloc(sizeof(struct dirmonitor_internal), 1); struct dirmonitor_internal* monitor = calloc(sizeof(struct dirmonitor_internal), 1);
monitor->fd = inotify_init(); monitor->fd = inotify_init();
pipe(monitor->sig); pipe(monitor->sig);
fcntl(monitor->sig[0], F_SETFD, FD_CLOEXEC);
fcntl(monitor->sig[1], F_SETFD, FD_CLOEXEC);
return monitor; return monitor;
} }