Make sure pipes are closed on exec.

This commit is contained in:
Adam Harrison 2022-04-24 21:13:18 -04:00
parent 5df1640595
commit d8f202e251
1 changed files with 3 additions and 0 deletions

View File

@ -2,6 +2,7 @@
#include <sys/select.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
struct dirmonitor_internal {
@ -15,6 +16,8 @@ struct dirmonitor_internal* init_dirmonitor() {
struct dirmonitor_internal* monitor = calloc(sizeof(struct dirmonitor_internal), 1);
monitor->fd = inotify_init();
pipe(monitor->sig);
fcntl(monitor->sig[0], F_SETFD, FD_CLOEXEC);
fcntl(monitor->sig[1], F_SETFD, FD_CLOEXEC);
return monitor;
}