diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h index 6ad3a8282..a7fcb9086 100644 --- a/winsup/cygwin/fhandler.h +++ b/winsup/cygwin/fhandler.h @@ -495,7 +495,7 @@ public: void create_guard (SECURITY_ATTRIBUTES *sa) {guard = CreateMutex (sa, FALSE, NULL);} int dup (fhandler_base *child); int ioctl (unsigned int cmd, void *); - void fixup_after_fork (HANDLE); + virtual void fixup_after_fork (HANDLE); void fixup_after_exec (); bool hit_eof (); void set_eof () {broken_pipe = true;} @@ -509,7 +509,6 @@ public: class fhandler_fifo: public fhandler_pipe { HANDLE output_handle; - HANDLE owner; // You can't have too many mutexes, now, can you? long read_use; long write_use; virtual HANDLE& get_io_handle () { return io_handle ?: output_handle; } diff --git a/winsup/cygwin/fhandler_disk_file.cc b/winsup/cygwin/fhandler_disk_file.cc index 280aa0779..2865d8787 100644 --- a/winsup/cygwin/fhandler_disk_file.cc +++ b/winsup/cygwin/fhandler_disk_file.cc @@ -219,7 +219,7 @@ fhandler_base::fstat_fs (struct __stat64 *buf) if (get_io_handle ()) { - if (nohandle ()) + if (nohandle () || is_fs_special ()) return fstat_by_name (buf); else return fstat_by_handle (buf); @@ -325,7 +325,7 @@ fhandler_base::fstat_helper (struct __stat64 *buf, buf->st_blocks = (nAllocSize + S_BLKSIZE - 1) / S_BLKSIZE; else if (pc.has_attribute (FILE_ATTRIBUTE_COMPRESSED | FILE_ATTRIBUTE_SPARSE_FILE) - && get_io_handle () + && get_io_handle () && !is_fs_special () && !NtQueryInformationFile (get_io_handle (), &st, (PVOID) &fci, sizeof fci, FileCompressionInformation)) /* Otherwise we request the actual amount of bytes allocated for @@ -352,8 +352,8 @@ fhandler_base::fstat_helper (struct __stat64 *buf, else if (pc.issocket ()) buf->st_mode = S_IFSOCK; - if (!get_file_attribute (pc.has_acls (), get_io_handle (), get_win32_name (), - &buf->st_mode, &buf->st_uid, &buf->st_gid)) + if (!get_file_attribute (pc.has_acls (), is_fs_special () ? NULL: get_io_handle (), + get_win32_name (), &buf->st_mode, &buf->st_uid, &buf->st_gid)) { /* If read-only attribute is set, modify ntsec return value */ if (pc.has_attribute (FILE_ATTRIBUTE_READONLY) && !pc.issymlink ()) @@ -373,7 +373,7 @@ fhandler_base::fstat_helper (struct __stat64 *buf, { buf->st_mode |= STD_RBITS; - if (!pc.has_attribute (FILE_ATTRIBUTE_READONLY)) + if (!pc.has_attribute (FILE_ATTRIBUTE_READONLY) && !pc.issymlink ()) buf->st_mode |= STD_WBITS; /* | S_IWGRP | S_IWOTH; we don't give write to group etc */ diff --git a/winsup/cygwin/fhandler_fifo.cc b/winsup/cygwin/fhandler_fifo.cc index 5431f1005..b654dc2dd 100644 --- a/winsup/cygwin/fhandler_fifo.cc +++ b/winsup/cygwin/fhandler_fifo.cc @@ -100,7 +100,7 @@ fhandler_fifo::open_not_mine (int flags) __seterrno (); goto out; } - if (!DuplicateHandle (hMainProc, fh->get_handle (), hMainProc, + if (!DuplicateHandle (hMainProc, fh->get_output_handle (), hMainProc, &r.handles[1], 0, false, DUPLICATE_SAME_ACCESS)) { CloseHandle (r.handles[0]); @@ -146,14 +146,14 @@ fhandler_fifo::open (int flags, mode_t) goto out; fhandler_pipe *fhs[2]; - if (create (fhs, 0, flags, true)) + if (create (fhs, 1, flags, true)) { __seterrno (); res = 0; } else { - set_flags (fhs[0]->get_flags ()); + set_flags (flags); set_io_handle (fhs[0]->get_handle ()); set_output_handle (fhs[1]->get_handle ()); guard = fhs[0]->guard; diff --git a/winsup/cygwin/pinfo.cc b/winsup/cygwin/pinfo.cc index 1162e7b1b..79829e3c6 100644 --- a/winsup/cygwin/pinfo.cc +++ b/winsup/cygwin/pinfo.cc @@ -610,6 +610,7 @@ _pinfo::commune_recv () it[0] = it[1] = NULL; /* FIXME: possibly left a handle open in child? */ break; } + debug_printf ("fifo found %p, %p", it[0], it[1]); } CloseHandle (hp);