From ccb73f8bf9191c01c90975958a210c47175bd98c Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Sat, 26 Jul 2014 13:27:07 -0500 Subject: Default xcreate/xopen to O_CLOEXEC. (Pass O_CLOEXEC in the flags to switch it back off.) This way we're not leaking filehandles to children from things like find -exec. --- lib/xwrap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/xwrap.c') diff --git a/lib/xwrap.c b/lib/xwrap.c index 583a4cae..4516250f 100644 --- a/lib/xwrap.c +++ b/lib/xwrap.c @@ -218,7 +218,7 @@ void xunlink(char *path) // Die unless we can open/create a file, returning file descriptor. int xcreate(char *path, int flags, int mode) { - int fd = open(path, flags, mode); + int fd = open(path, flags^O_CLOEXEC, mode); if (fd == -1) perror_exit("%s", path); return fd; } -- cgit v1.2.3