Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2001-09-22 20:55:02 +0400
committerChristopher Faylor <me@cgf.cx>2001-09-22 20:55:02 +0400
commit5e733918c085833e32581ac0bb0437b00ad2aa8e (patch)
tree1a6e4725f8c88ede60c41c445c98d685224cd85a /winsup/cygwin/pipe.cc
parent142920f65aeeefc29ef903b75b6327668341bc8e (diff)
* exceptions.cc (setup_handler): Always relinquish lock after we've
interrupted. * fhandler.cc: Move pipe methods to pipe.cc. * fhandler.h (fhandler_pipe): Add new methods. * fork.cc (sync_with_parent): Make error messages more informative. * pipe.cc (fhandler_pipe::fhandler_pipe): Move here from fhandler.cc. (fhandler_pipe::lseek): Ditto. (fhandler_pipe::set_close_on_exec): New method. (fhandler_pipe::read): Ditto. (fhandler_pipe::close): Ditto. (fhandler_pipe::dup): Ditto. (make_pipe): Create the guard mutex on the read side of the pipe. * select.cc (peek_pipe): Use guard_mutex to discover if we have the right to read on this pipe. (fhandler_pipe::readh_for_read): Pass the read pipe guard mutex to peek_pipe. * syscalls.cc (_read): Always detect signal catchers, for now. * debug.cc (makethread): Eliminate hack to make thread inheritable. * sigproc.cc (subproc_init): Don't use hack to make thread inheritable.
Diffstat (limited to 'winsup/cygwin/pipe.cc')
-rw-r--r--winsup/cygwin/pipe.cc55
1 files changed, 55 insertions, 0 deletions
diff --git a/winsup/cygwin/pipe.cc b/winsup/cygwin/pipe.cc
index 1c1d0ad80..04a1fbece 100644
--- a/winsup/cygwin/pipe.cc
+++ b/winsup/cygwin/pipe.cc
@@ -19,6 +19,60 @@ details. */
#include "cygheap.h"
#include "thread.h"
+fhandler_pipe::fhandler_pipe (const char *name, DWORD devtype) :
+ fhandler_base (devtype, name), guard (0)
+{
+ set_cb (sizeof *this);
+}
+
+off_t
+fhandler_pipe::lseek (off_t offset, int whence)
+{
+ debug_printf ("(%d, %d)", offset, whence);
+ set_errno (ESPIPE);
+ return -1;
+}
+
+void
+fhandler_pipe::set_close_on_exec (int val)
+{
+ this->fhandler_base::set_close_on_exec (val);
+ set_inheritance (guard, val);
+}
+
+int
+fhandler_pipe::read (void *in_ptr, size_t in_len)
+{
+ int res = this->fhandler_base::read (in_ptr, in_len);
+ ReleaseMutex (guard);
+ return res;
+}
+
+int fhandler_pipe::close ()
+{
+ int res = this->fhandler_base::close ();
+ if (guard)
+ CloseHandle (guard);
+ return res;
+}
+
+int
+fhandler_pipe::dup (fhandler_base *child)
+{
+ int res = this->fhandler_base::dup (child);
+ if (res)
+ return res;
+
+ fhandler_pipe *ftp = (fhandler_pipe *) child;
+
+ if (guard == NULL)
+ ftp->guard = NULL;
+ else if (!DuplicateHandle (hMainProc, guard, hMainProc, &ftp->guard, 0, 1,
+ DUPLICATE_SAME_ACCESS))
+ return -1;
+ return 0;
+}
+
static int
make_pipe (int fildes[2], unsigned int psize, int mode)
{
@@ -53,6 +107,7 @@ make_pipe (int fildes[2], unsigned int psize, int mode)
fildes[1] = fdw;
res = 0;
+ fhr->create_guard (sa);
}
syscall_printf ("%d = make_pipe ([%d, %d], %d, %p)", res, fdr, fdw, psize, mode);