-/* Copyright (C) 1991 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1992 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
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
+#include <hurd.h>
/* Duplicate FD to FD2, closing the old FD2 and making FD2 be
int
DEFUN(__dup2, (fd, fd2), int fd AND int fd2)
{
- __mutex_lock (&_hurd_dtable.lock);
+ __mutex_lock (&_hurd_dtable_lock);
if (fd < 0 || fd >= _hurd_dtable.size ||
_hurd_dtable.d[fd].server == MACH_PORT_NULL ||
fd2 < 0 || fd2 >= _hurd_dtable.size)
{
- __mutex_unlock (&_hurd_dtable.lock);
+ __mutex_unlock (&_hurd_dtable_lock);
errno = EBADF;
return -1;
}
if (_hurd_dtable.d[fd2].server != MACH_PORT_NULL)
__mach_port_deallocate (__mach_task_self (), _hurd_dtable.d[fd2].server);
- _hurd_dtable.d[fd2].server = _hurd_dtable.d[fd].server;
- _hurd_dtable.d[fd2].isctty = _hurd_dtable.d[fd].isctty;
+ _hurd_dtable.d[fd2] = _hurd_dtable.d[fd];
__mach_port_mod_refs (__mach_task_self (), _hurd_dtable.d[fd].server,
MACH_PORT_RIGHT_SEND, 1);
- __mutex_unlock (&_hurd_dtable.lock);
+ __mutex_unlock (&_hurd_dtable_lock);
return fd2;
}