[PATCH 15/46] dup3: Add dup3 syscall
Markos Chandras
markos.chandras at gmail.com
Tue Nov 13 11:31:24 UTC 2012
From: Markos Chandras <markos.chandras at imgtec.com>
Signed-off-by: Markos Chandras <markos.chandras at imgtec.com>
---
include/unistd.h | 4 ++++
libc/sysdeps/linux/common/dup3.c | 17 +++++++++++++++++
2 files changed, 21 insertions(+), 0 deletions(-)
create mode 100644 libc/sysdeps/linux/common/dup3.c
diff --git a/include/unistd.h b/include/unistd.h
index 1b2fd4d..82e24a4 100644
--- a/include/unistd.h
+++ b/include/unistd.h
@@ -513,6 +513,10 @@ extern int dup (int __fd) __THROW __wur;
extern int dup2 (int __fd, int __fd2) __THROW;
libc_hidden_proto(dup2)
+/* Duplicate FD to FD2, closing FD2 and making it open on the same file. */
+extern int dup3 (int __fd, int __fd2, int __flags) __THROW;
+libc_hidden_proto(dup3)
+
/* NULL-terminated array of "NAME=VALUE" environment variables. */
extern char **__environ;
#ifdef __USE_GNU
diff --git a/libc/sysdeps/linux/common/dup3.c b/libc/sysdeps/linux/common/dup3.c
new file mode 100644
index 0000000..3e7c813
--- /dev/null
+++ b/libc/sysdeps/linux/common/dup3.c
@@ -0,0 +1,17 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * dup3() for uClibc
+ *
+ * Copyright (C) 2000-2006 Erik Andersen <andersen at uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <sys/syscall.h>
+#include <unistd.h>
+
+
+#if defined(__NR_dup3)
+_syscall3(int, dup3, int, oldfd, int, newfd, int, flags)
+libc_hidden_def(dup3)
+#endif
--
1.7.1
More information about the uClibc
mailing list