]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - hurd/port2fd.c
Fix BZ #21654 - grp-merge.c alignment
[thirdparty/glibc.git] / hurd / port2fd.c
index 48b74f1addc2e1a3320130b093e4b64a6b75aa51..83e7b9c47eda5eb79d186cda998e442159bd658c 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1994, 1997, 1999 Free Software Foundation, Inc.
+/* Copyright (C) 1994-2017 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
@@ -12,9 +12,8 @@
    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.  */
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
 
 #include <hurd.h>
 #include <hurd/fd.h>
@@ -23,7 +22,7 @@
 #include <fcntl.h>
 
 /* Store PORT in file descriptor D, doing appropriate ctty magic.
-   FLAGS are as for `open'; only O_IGNORE_CTTY is meaningful.
+   FLAGS are as for `open'; only O_IGNORE_CTTY and O_CLOEXEC are meaningful.
    D should be locked, and will not be unlocked.  */
 
 void
@@ -55,7 +54,7 @@ _hurd_port2fd (struct hurd_fd *d, io_t dport, int flags)
     mach_port_t old
       = _hurd_userlink_clear (&d->port.users) ? d->port.port : MACH_PORT_NULL;
     d->port.port = dport;
-    d->flags = 0;
+    d->flags = (flags & O_CLOEXEC) ? FD_CLOEXEC : 0;
     if (old != MACH_PORT_NULL)
       __mach_port_deallocate (__mach_task_self (), old);
   }