summaryrefslogtreecommitdiff
path: root/sysdeps/mach/hurd
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/mach/hurd')
-rw-r--r--sysdeps/mach/hurd/bits/fcntl.h9
-rw-r--r--sysdeps/mach/hurd/fcntl.c12
-rw-r--r--sysdeps/mach/hurd/kernel-features.h31
3 files changed, 48 insertions, 4 deletions
diff --git a/sysdeps/mach/hurd/bits/fcntl.h b/sysdeps/mach/hurd/bits/fcntl.h
index 34e6baa049..2f890c1b65 100644
--- a/sysdeps/mach/hurd/bits/fcntl.h
+++ b/sysdeps/mach/hurd/bits/fcntl.h
@@ -71,7 +71,6 @@
#define O_SYNC O_FSYNC
#ifdef __USE_GNU
# define O_NOATIME 0x0800 /* Don't set access time on read (owner). */
-# define O_CLOEXEC 0x00010000 /* Set FD_CLOEXEC. */
#endif
#ifdef __USE_MISC
# define O_SHLOCK 0x00020000 /* Open with shared file lock. */
@@ -118,6 +117,9 @@
once the file has been opened. */
#define O_TRUNC 0x00010000 /* Truncate file to zero length. */
+#ifdef __USE_GNU
+# define O_CLOEXEC 0x00400000 /* Set FD_CLOEXEC. */
+#endif
/* Controlling terminal flags. These are understood only by `open',
@@ -163,6 +165,11 @@
#define F_SETLK 8 /* Set record locking info (non-blocking). */
#define F_SETLKW 9 /* Set record locking info (blocking). */
+#ifdef __USE_GNU
+# define F_DUPFD_CLOEXEC 1030 /* Duplicate, set FD_CLOEXEC on new one. */
+#endif
+
+
/* File descriptor flags used with F_GETFD and F_SETFD. */
#define FD_CLOEXEC 1 /* Close on exec. */
diff --git a/sysdeps/mach/hurd/fcntl.c b/sysdeps/mach/hurd/fcntl.c
index d4e4aa5da1..470614b360 100644
--- a/sysdeps/mach/hurd/fcntl.c
+++ b/sysdeps/mach/hurd/fcntl.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1992-1997,1999,2000,2002 Free Software Foundation, Inc.
+/* Copyright (C) 1992-1997,1999,2000,2002,2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -50,6 +50,7 @@ __libc_fcntl (int fd, int cmd, ...)
/* First the descriptor-based commands, which do no RPCs. */
case F_DUPFD: /* Duplicate the file descriptor. */
+ case F_DUPFD_CLOEXEC:
{
struct hurd_fd *new;
io_t port, ctty;
@@ -64,6 +65,12 @@ __libc_fcntl (int fd, int cmd, ...)
ctty = _hurd_port_get (&d->ctty, &ctty_ulink);
port = _hurd_port_locked_get (&d->port, &ulink); /* Unlocks D. */
+ if (cmd == F_DUPFD_CLOEXEC)
+ flags |= FD_CLOEXEC;
+ else
+ /* Duplication clears the FD_CLOEXEC flag. */
+ flags &= ~FD_CLOEXEC;
+
/* Get a new file descriptor. The third argument to __fcntl is the
minimum file descriptor number for it. */
new = _hurd_alloc_fd (&result, va_arg (ap, int));
@@ -82,8 +89,7 @@ __libc_fcntl (int fd, int cmd, ...)
/* Install the ports and flags in the new descriptor. */
if (ctty != MACH_PORT_NULL)
_hurd_port_set (&new->ctty, ctty);
- /* Duplication clears the FD_CLOEXEC flag. */
- new->flags = flags & ~FD_CLOEXEC;
+ new->flags = flags;
_hurd_port_locked_set (&new->port, port); /* Unlocks NEW. */
}
diff --git a/sysdeps/mach/hurd/kernel-features.h b/sysdeps/mach/hurd/kernel-features.h
new file mode 100644
index 0000000000..ad159aace8
--- /dev/null
+++ b/sysdeps/mach/hurd/kernel-features.h
@@ -0,0 +1,31 @@
+/* Set flags signalling availability of certain operating system features.
+ Copyright (C) 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* This file can define __ASSUME_* macros checked by certain source files.
+ Almost none of these are used outside of sysdeps/unix/sysv/linux code.
+ But those referring to POSIX-level features like O_* flags can be. */
+
+#include <fcntl.h>
+
+/* If a system defines the O_CLOEXEC constant but it is sometimes ignored,
+ it must override this file to define __ASSUME_O_CLOEXEC conditionally
+ (or not at all) to indicate when O_CLOEXEC actually works. */
+#ifdef O_CLOEXEC
+# define __ASSUME_O_CLOEXEC 1
+#endif