fd_util: add function dup_cloexec()
Unfortunately, there's no "optimized" implementation here. We can't use Linux's proprietary system call dup3(), because it would require us to specify the new descriptor.
This commit is contained in:
@@ -103,6 +103,16 @@ fd_set_nonblock(int fd)
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
dup_cloexec(int oldfd)
|
||||
{
|
||||
int newfd = dup(oldfd);
|
||||
if (newfd >= 0)
|
||||
fd_set_nonblock(newfd);
|
||||
|
||||
return newfd;
|
||||
}
|
||||
|
||||
int
|
||||
open_cloexec(const char *path_fs, int flags, int mode)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user