1
0
mirror of https://github.com/osmarks/ngircd.git synced 2024-12-12 18:00:28 +00:00

io: add io_cloexec to set close-on-exec flag.

This commit is contained in:
Florian Westphal 2010-09-10 23:41:29 +02:00
parent 1e281a8baa
commit c135d0dded
2 changed files with 13 additions and 0 deletions

View File

@ -785,6 +785,16 @@ io_setnonblock(int fd)
return fcntl(fd, F_SETFL, flags) == 0; 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 bool
io_close(int fd) io_close(int fd)

View File

@ -45,6 +45,9 @@ bool io_close PARAMS((int fd));
/* set O_NONBLOCK */ /* set O_NONBLOCK */
bool io_setnonblock PARAMS((int fd)); bool io_setnonblock PARAMS((int fd));
/* set O_CLOEXEC */
bool io_setcloexec PARAMS((int fd));
/* watch fds for activity */ /* watch fds for activity */
int io_dispatch PARAMS((struct timeval *tv)); int io_dispatch PARAMS((struct timeval *tv));