From: Florian Westphal Date: Fri, 10 Sep 2010 21:41:29 +0000 (+0200) Subject: io: add io_cloexec to set close-on-exec flag. X-Git-Tag: rel-17-rc1~25 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c135d0dded909e2e5780697c4066ad44a3f488c8;p=ngircd io: add io_cloexec to set close-on-exec flag. --- 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));