mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-03-05 22:46:03 +08:00
Cygwin: AF_UNIX: SCM_RIGHTS: support tape descriptors
Untested.
This commit is contained in:
parent
d262fdde0d
commit
852e494f93
winsup/cygwin
@ -2034,8 +2034,8 @@ fhandler_socket_unix::serialize (int fd)
|
||||
case DEV_SD_MAJOR:
|
||||
case DEV_SD1_MAJOR ... DEV_SD7_MAJOR:
|
||||
case DEV_SD_HIGHPART_START ... DEV_SD_HIGHPART_END:
|
||||
break;
|
||||
case DEV_TAPE_MAJOR:
|
||||
break;
|
||||
case DEV_SERIAL_MAJOR:
|
||||
set_errno (EOPNOTSUPP);
|
||||
goto out;
|
||||
@ -2137,8 +2137,8 @@ fhandler_socket_unix::deserialize (void *bufp)
|
||||
case DEV_SD_MAJOR:
|
||||
case DEV_SD1_MAJOR ... DEV_SD7_MAJOR:
|
||||
case DEV_SD_HIGHPART_START ... DEV_SD_HIGHPART_END:
|
||||
break;
|
||||
case DEV_TAPE_MAJOR:
|
||||
break;
|
||||
case DEV_SERIAL_MAJOR:
|
||||
set_errno (EOPNOTSUPP);
|
||||
return -1;
|
||||
|
@ -1469,31 +1469,45 @@ fhandler_dev_tape::fstat (struct stat *buf)
|
||||
}
|
||||
|
||||
int
|
||||
fhandler_dev_tape::dup (fhandler_base *child, int flags, DWORD)
|
||||
fhandler_dev_tape::dup (fhandler_base *child, int flags, DWORD src_pid)
|
||||
{
|
||||
HANDLE src_proc = GetCurrentProcess ();
|
||||
if (src_pid && !(src_proc = OpenProcess (PROCESS_DUP_HANDLE, false, src_pid)))
|
||||
{
|
||||
debug_printf ("can't open source process %d, %E", src_pid);
|
||||
return -1;
|
||||
}
|
||||
|
||||
lock (-1);
|
||||
fhandler_dev_tape *fh = (fhandler_dev_tape *) child;
|
||||
if (!DuplicateHandle (GetCurrentProcess (), mt_mtx,
|
||||
if (!DuplicateHandle (src_proc, mt_mtx,
|
||||
GetCurrentProcess (), &fh->mt_mtx,
|
||||
0, TRUE, DUPLICATE_SAME_ACCESS))
|
||||
{
|
||||
debug_printf ("dup(%s) failed, mutex handle %p, %E",
|
||||
get_name (), mt_mtx);
|
||||
__seterrno ();
|
||||
return unlock (-1);
|
||||
goto err;
|
||||
}
|
||||
fh->ov.hEvent = NULL;
|
||||
if (ov.hEvent &&
|
||||
!DuplicateHandle (GetCurrentProcess (), ov.hEvent,
|
||||
!DuplicateHandle (src_proc, ov.hEvent,
|
||||
GetCurrentProcess (), &fh->ov.hEvent,
|
||||
0, TRUE, DUPLICATE_SAME_ACCESS))
|
||||
{
|
||||
debug_printf ("dup(%s) failed, event handle %p, %E",
|
||||
get_name (), ov.hEvent);
|
||||
__seterrno ();
|
||||
return unlock (-1);
|
||||
goto err_close_mt_mtx;
|
||||
}
|
||||
if (src_proc != GetCurrentProcess ())
|
||||
CloseHandle (src_proc);
|
||||
return unlock (fhandler_dev_raw::dup (child, flags));
|
||||
err_close_mt_mtx:
|
||||
CloseHandle (fh->mt_mtx);
|
||||
err:
|
||||
__seterrno ();
|
||||
if (src_proc != GetCurrentProcess ())
|
||||
CloseHandle (src_proc);
|
||||
return unlock (-1);
|
||||
}
|
||||
|
||||
void
|
||||
|
Loading…
x
Reference in New Issue
Block a user