* 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.
This commit is contained in:
Christopher Faylor
2001-09-22 16:55:02 +00:00
parent 142920f65a
commit 5e733918c0
10 changed files with 120 additions and 56 deletions

View File

@@ -123,14 +123,6 @@ cygwin_select (int maxfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
fd_set *dummy_exceptfds = allocfd_set (maxfds);
sigframe thisframe (mainthread);
#if 0
if (n > FD_SETSIZE)
{
set_errno (EINVAL);
return -1;
}
#endif
select_printf ("%d, %p, %p, %p, %p", maxfds, readfds, writefds, exceptfds, to);
if (!readfds)
@@ -407,7 +399,7 @@ no_verify (select_record *, fd_set *, fd_set *, fd_set *)
}
static int
peek_pipe (select_record *s, int ignra)
peek_pipe (select_record *s, int ignra, HANDLE guard_mutex = NULL)
{
int n = 0;
int gotone = 0;
@@ -454,8 +446,15 @@ peek_pipe (select_record *s, int ignra)
}
}
if (fh->get_device() != FH_PIPEW &&
!PeekNamedPipe (h, NULL, 0, NULL, (DWORD *) &n, NULL))
if (fh->get_device () == FH_PIPEW)
/* nothing */;
else if (guard_mutex && WaitForSingleObject (guard_mutex, 0) != WAIT_OBJECT_0)
{
select_printf ("%s, couldn't get mutex %p, %E", fh->get_name (),
guard_mutex);
n = 0;
}
else if (!PeekNamedPipe (h, NULL, 0, NULL, (DWORD *) &n, NULL))
{
select_printf ("%s, PeekNamedPipe failed, %E", fh->get_name ());
n = -1;
@@ -496,8 +495,20 @@ poll_pipe (select_record *me, fd_set *readfds, fd_set *writefds,
set_bits (me, readfds, writefds, exceptfds) :
0;
}
MAKEready(pipe)
int
fhandler_pipe::ready_for_read (int fd, DWORD howlong, int ignra)
{
select_record me (this);
me.fd = fd;
(void) select_read (&me);
while (!peek_pipe (&me, ignra, guard) && howlong == INFINITE)
if (fd >= 0 && cygheap->fdtab.not_open (fd))
break;
else if (WaitForSingleObject (signal_arrived, 10) == WAIT_OBJECT_0)
break;
select_printf ("returning %d", me.read_ready);
return me.read_ready;
}
static int start_thread_pipe (select_record *me, select_stuff *stuff);