]> arthur.barton.de Git - ngircd-alex.git/commitdiff
io: add io_cloexec to set close-on-exec flag.
authorFlorian Westphal <fw@strlen.de>
Fri, 10 Sep 2010 21:41:29 +0000 (23:41 +0200)
committerFlorian Westphal <fw@strlen.de>
Sat, 11 Sep 2010 09:36:12 +0000 (11:36 +0200)
src/ngircd/io.c
src/ngircd/io.h

index cb2b55a9297d9c0285f1be1a5d4db370f0fedb95..6843899d5b61e280895e20577072c98282b464f9 100644 (file)
@@ -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)
index a2285de4abfd3ec3f28fe9792f802bcd2a5886fa..2f4c964551d31627ae8ba743b700378979d6cc9c 100644 (file)
@@ -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));