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:
parent
1e281a8baa
commit
c135d0dded
@ -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)
|
||||||
|
@ -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));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user