Module: ngircd.git Branch: master Commit: c135d0dded909e2e5780697c4066ad44a3f488c8 URL: http://ngircd.barton.de/cgi-bin/gitweb.cgi?p=ngircd.git&a=commit;h=c135d...
Author: Florian Westphal fw@strlen.de Date: Fri Sep 10 23:41:29 2010 +0200
io: add io_cloexec to set close-on-exec flag.
---
src/ngircd/io.c | 10 ++++++++++ src/ngircd/io.h | 3 +++ 2 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/src/ngircd/io.c b/src/ngircd/io.c index cb2b55a..6843899 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 a2285de..2f4c964 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));
ngircd-commits@lists.barton.de