commit c135d0dded909e2e5780697c4066ad44a3f488c8 from: Florian Westphal date: Sat Sep 11 09:36:12 2010 UTC io: add io_cloexec to set close-on-exec flag. commit - 1e281a8baa5dc0499ad8f0b75d5f366b498511f6 commit + c135d0dded909e2e5780697c4066ad44a3f488c8 blob - cb2b55a9297d9c0285f1be1a5d4db370f0fedb95 blob + 6843899d5b61e280895e20577072c98282b464f9 --- src/ngircd/io.c +++ src/ngircd/io.c @@ -784,7 +784,17 @@ 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) blob - a2285de4abfd3ec3f28fe9792f802bcd2a5886fa blob + 2f4c964551d31627ae8ba743b700378979d6cc9c --- src/ngircd/io.h +++ 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));