aboutsummaryrefslogtreecommitdiffstats
path: root/src/fd_util.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2010-08-03 18:03:55 +0200
committerMax Kellermann <max@duempel.org>2010-08-03 18:03:55 +0200
commit68c02fc95af57a0b3be64aa214125be2d3ed1cf7 (patch)
treebaf4db9e06b50ac07555a8d89d9885cdf3dce916 /src/fd_util.c
parentd18c1b1a0ab57d77ba823cfedf40077d24dafbd7 (diff)
downloadmpd-68c02fc95af57a0b3be64aa214125be2d3ed1cf7.tar.gz
mpd-68c02fc95af57a0b3be64aa214125be2d3ed1cf7.tar.xz
mpd-68c02fc95af57a0b3be64aa214125be2d3ed1cf7.zip
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.
Diffstat (limited to 'src/fd_util.c')
-rw-r--r--src/fd_util.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/fd_util.c b/src/fd_util.c
index b9443b03d..769823bc4 100644
--- a/src/fd_util.c
+++ b/src/fd_util.c
@@ -104,6 +104,16 @@ fd_set_nonblock(int fd)
}
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)
{
int fd;