2007-10-17 Roland McGrath <roland@frob.com>
* sysdeps/mach/hurd/bits/fcntl.h [__USE_GNU__] (F_DUPFD_CLOEXEC): New. * sysdeps/mach/hurd/fcntl.c (__libc_fcntl): Implement it.
This commit is contained in:
parent
f71cda6a38
commit
bd92328d5e
|
@ -163,6 +163,11 @@
|
||||||
#define F_SETLK 8 /* Set record locking info (non-blocking). */
|
#define F_SETLK 8 /* Set record locking info (non-blocking). */
|
||||||
#define F_SETLKW 9 /* Set record locking info (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. */
|
/* File descriptor flags used with F_GETFD and F_SETFD. */
|
||||||
#define FD_CLOEXEC 1 /* Close on exec. */
|
#define FD_CLOEXEC 1 /* Close on exec. */
|
||||||
|
|
||||||
|
|
|
@ -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.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
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. */
|
/* First the descriptor-based commands, which do no RPCs. */
|
||||||
|
|
||||||
case F_DUPFD: /* Duplicate the file descriptor. */
|
case F_DUPFD: /* Duplicate the file descriptor. */
|
||||||
|
case F_DUPFD_CLOEXEC:
|
||||||
{
|
{
|
||||||
struct hurd_fd *new;
|
struct hurd_fd *new;
|
||||||
io_t port, ctty;
|
io_t port, ctty;
|
||||||
|
@ -64,6 +65,12 @@ __libc_fcntl (int fd, int cmd, ...)
|
||||||
ctty = _hurd_port_get (&d->ctty, &ctty_ulink);
|
ctty = _hurd_port_get (&d->ctty, &ctty_ulink);
|
||||||
port = _hurd_port_locked_get (&d->port, &ulink); /* Unlocks D. */
|
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
|
/* Get a new file descriptor. The third argument to __fcntl is the
|
||||||
minimum file descriptor number for it. */
|
minimum file descriptor number for it. */
|
||||||
new = _hurd_alloc_fd (&result, va_arg (ap, int));
|
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. */
|
/* Install the ports and flags in the new descriptor. */
|
||||||
if (ctty != MACH_PORT_NULL)
|
if (ctty != MACH_PORT_NULL)
|
||||||
_hurd_port_set (&new->ctty, ctty);
|
_hurd_port_set (&new->ctty, ctty);
|
||||||
/* Duplication clears the FD_CLOEXEC flag. */
|
new->flags = flags;
|
||||||
new->flags = flags & ~FD_CLOEXEC;
|
|
||||||
_hurd_port_locked_set (&new->port, port); /* Unlocks NEW. */
|
_hurd_port_locked_set (&new->port, port); /* Unlocks NEW. */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue