[klibc] Add dup3() system call

The dup3() system call allows a file descriptor to be duped with the
O_CLOEXEC flag set.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
diff --git a/usr/include/unistd.h b/usr/include/unistd.h
index 3eaeaee..3244e21 100644
--- a/usr/include/unistd.h
+++ b/usr/include/unistd.h
@@ -103,6 +103,7 @@
 
 __extern int dup(int);
 __extern int dup2(int, int);
+__extern int dup3(int, int, int);
 __extern int fcntl(int, int, ...);
 __extern int ioctl(int, int, void *);
 __extern int ftruncate(int, off_t);
diff --git a/usr/klibc/SYSCALLS.def b/usr/klibc/SYSCALLS.def
index 35bcdcf..5fd2753 100644
--- a/usr/klibc/SYSCALLS.def
+++ b/usr/klibc/SYSCALLS.def
@@ -165,6 +165,7 @@
 <32> int _llseek::__llseek(int, unsigned long, unsigned long, off_t *, int);
 int dup(int);
 int dup2(int, int);
+int dup3(int, int, int);
 <i386> int fcntl64@varadic::fcntl(int, int, unsigned long);
 <ppc64> int fcntl(int, int, unsigned long);
 <!i386,ppc64> int fcntl64,fcntl::fcntl(int, int, unsigned long);