diff options
| author | Florian Westphal <fw@strlen.de> | 2010-09-10 23:41:29 +0200 |
|---|---|---|
| committer | Florian Westphal <fw@strlen.de> | 2010-09-11 11:36:12 +0200 |
| commit | c135d0dded909e2e5780697c4066ad44a3f488c8 (patch) | |
| tree | 992a43118b164b690bebe45956c4c58af1d093a9 /src | |
| parent | 1e281a8baa5dc0499ad8f0b75d5f366b498511f6 (diff) | |
| download | ngircd-c135d0dded909e2e5780697c4066ad44a3f488c8.tar.gz ngircd-c135d0dded909e2e5780697c4066ad44a3f488c8.zip | |
io: add io_cloexec to set close-on-exec flag.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ngircd/io.c | 10 | ||||
| -rw-r--r-- | 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 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)); |