summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ngircd/io.c10
-rw-r--r--src/ngircd/io.h3
2 files changed, 13 insertions, 0 deletions
diff --git a/src/ngircd/io.c b/src/ngircd/io.c
index cb2b55a9..6843899d 100644
--- a/src/ngircd/io.c
+++ b/src/ngircd/io.c
@@ -785,6 +785,16 @@ io_setnonblock(int fd)
 	return fcntl(fd, F_SETFL, flags) == 0;
 }
 
+bool
+io_setcloexec(int fd)
+{
+	int flags = fcntl(fd, F_GETFD);
+	if (flags == -1)
+		return false;
+	flags |= FD_CLOEXEC;
+
+	return fcntl(fd, F_SETFD, flags) == 0;
+}
 
 bool
 io_close(int fd)
diff --git a/src/ngircd/io.h b/src/ngircd/io.h
index a2285de4..2f4c9645 100644
--- a/src/ngircd/io.h
+++ b/src/ngircd/io.h
@@ -45,6 +45,9 @@ bool io_close PARAMS((int fd));
 /* set O_NONBLOCK */
 bool io_setnonblock PARAMS((int fd));
 
+/* set O_CLOEXEC */
+bool io_setcloexec PARAMS((int fd));
+
 /* watch fds for activity */
 int io_dispatch PARAMS((struct timeval *tv));