* fhandler_console.cc (fhandler_console::read): Don't even think about breaking

on interrupt if executing in a "cygwin" thread.
* fhandler_tty.cc (fhandler_pty_master::process_slave_output): Streamline,
simplify code.
* sigproc.cc (sig_send): Remove debugging statement.
This commit is contained in:
Christopher Faylor 2000-03-12 04:44:37 +00:00
parent 1e8b88023c
commit 774ea16211
4 changed files with 153 additions and 126 deletions

View File

@ -1,3 +1,15 @@
Sat Mar 11 22:47:43 2000 Christopher Faylor <cgf@cygnus.com>
* fhandler_console.cc (fhandler_console::read): Don't even think about
breaking on interrupt if executing in a "cygwin" thread.
* fhandler_tty.cc (fhandler_pty_master::process_slave_output):
Streamline, simplify code.
* sigproc.cc (sig_send): Remove debugging statement.
Sat Mar 11 22:46:55 2000 Christopher Faylor <cgf@cygnus.com>
* fhandler_console.cc (fhandler_console::read)
Fri Mar 10 13:20:50 2000 Christopher Faylor <cgf@cygnus.com> Fri Mar 10 13:20:50 2000 Christopher Faylor <cgf@cygnus.com>
* sigproc.cc: Set wait_sig priority to normal. * sigproc.cc: Set wait_sig priority to normal.

View File

@ -137,8 +137,13 @@ fhandler_console::read (void *pv, size_t buflen)
DWORD nwait; DWORD nwait;
w4[0] = h; w4[0] = h;
nwait = 2; if (iscygthread ())
nwait = 1;
else
{
w4[1] = signal_arrived; w4[1] = signal_arrived;
nwait = 2;
}
for (;;) for (;;)
{ {
@ -151,7 +156,6 @@ fhandler_console::read (void *pv, size_t buflen)
case WAIT_OBJECT_0: case WAIT_OBJECT_0:
break; break;
case WAIT_OBJECT_0 + 1: case WAIT_OBJECT_0 + 1:
if (!iscygthread ())
set_sig_errno (EINTR); set_sig_errno (EINTR);
return -1; return -1;
default: default:

View File

@ -154,7 +154,8 @@ void
fhandler_pty_master::doecho (const void *str, DWORD len) fhandler_pty_master::doecho (const void *str, DWORD len)
{ {
acquire_output_mutex (INFINITE); acquire_output_mutex (INFINITE);
WriteFile (get_ttyp ()->to_master, str, len, &len, NULL); if (!WriteFile (get_ttyp ()->to_master, str, len, &len, NULL))
termios_printf ("Write to %p failed, %E", get_ttyp ()->to_master);
// WaitForSingleObject (output_done_event, INFINITE); // WaitForSingleObject (output_done_event, INFINITE);
release_output_mutex (); release_output_mutex ();
} }
@ -219,12 +220,13 @@ fhandler_pty_master::process_slave_output (char *buf, size_t len)
char outbuf[OUT_BUFFER_SIZE]; char outbuf[OUT_BUFFER_SIZE];
DWORD n; DWORD n;
int column = 0; int column = 0;
int rc = 0;
again:
if (len == 0) if (len == 0)
return 0; goto out;
for (;;)
{
if (neednl_) if (neednl_)
{ {
/* We need to return a left over \n character, resulting from /* We need to return a left over \n character, resulting from
@ -233,7 +235,8 @@ again:
don't check again here. */ don't check again here. */
buf[0] = '\n'; buf[0] = '\n';
neednl_ = 0; neednl_ = 0;
return 1; rc = 1;
break;
} }
/* Set RLEN to the number of bytes to read from the pipe. */ /* Set RLEN to the number of bytes to read from the pipe. */
@ -254,48 +257,44 @@ again:
/* Doing a busy wait like this is quite inefficient, but nothing /* Doing a busy wait like this is quite inefficient, but nothing
else seems to work completely. Windows should provide some sort else seems to work completely. Windows should provide some sort
of overlapped I/O for pipes, or something, but it doesn't. */ of overlapped I/O for pipes, or something, but it doesn't. */
DWORD avail;
while (1) while (1)
{ {
DWORD avail;
if (!PeekNamedPipe (handle, NULL, 0, NULL, &avail, NULL)) if (!PeekNamedPipe (handle, NULL, 0, NULL, &avail, NULL))
{ goto err;
if (GetLastError () == ERROR_BROKEN_PIPE)
return 0;
__seterrno ();
return -1;
}
if (avail > 0) if (avail > 0)
break; break;
if (hit_eof ()) if (hit_eof ())
return 0; goto out;
Sleep (10); Sleep (10);
} }
if (ReadFile (handle, outbuf, rlen, &n, NULL) == FALSE) if (ReadFile (handle, outbuf, rlen, &n, NULL) == FALSE)
{ goto err;
if (GetLastError () == ERROR_BROKEN_PIPE)
return 0;
__seterrno ();
return -1;
}
termios_printf ("len=%u", n); termios_printf ("rlen %u", n);
if (get_ttyp ()->ti.c_lflag & FLUSHO) if (get_ttyp ()->ti.c_lflag & FLUSHO)
{ {
get_ttyp ()->write_retval = n; get_ttyp ()->write_retval = n;
if (output_done_event != NULL) if (output_done_event != NULL)
SetEvent (output_done_event); SetEvent (output_done_event);
goto again; continue;
} }
if (get_ttyp ()->OutputStopped) if (get_ttyp ()->OutputStopped)
{ {
termios_printf ("waiting for restart_output_event"); termios_printf ("waiting for restart_output_event");
WaitForSingleObject (restart_output_event, INFINITE); WaitForSingleObject (restart_output_event, INFINITE);
termios_printf ("done waiting for restart_output_event");
} }
if (get_ttyp ()->ti.c_oflag & OPOST) // post-process output if (!(get_ttyp ()->ti.c_oflag & OPOST)) // post-process output
{
memcpy (buf, outbuf, n);
rc = n;
}
else // raw output mode
{ {
char *iptr = outbuf, *optr = buf; char *iptr = outbuf, *optr = buf;
@ -341,13 +340,24 @@ again:
*optr++ = *iptr++; *optr++ = *iptr++;
} }
return optr - buf; rc = optr - buf;
} }
else // raw output mode break;
err:
if (GetLastError () == ERROR_BROKEN_PIPE)
rc = 0;
else
{ {
memcpy (buf, outbuf, n); __seterrno ();
return n; rc = -1;
} }
break;
}
out:
termios_printf ("returning %d", rc);
return rc;
} }
static DWORD WINAPI static DWORD WINAPI
@ -546,8 +556,10 @@ fhandler_tty_slave::write (const void *ptr, size_t len)
if (output_done_event != NULL) if (output_done_event != NULL)
{ {
termios_printf("tty%d waiting for output_done", ttynum); DWORD rc;
WaitForSingleObject (output_done_event, n * 1000); DWORD x = n * 1000;
rc = WaitForSingleObject (output_done_event, x);
termios_printf("waited %d ms for output_done_event, WFSO %d", x, rc);
} }
if (get_ttyp ()->write_retval < 0) if (get_ttyp ()->write_retval < 0)

View File

@ -826,7 +826,6 @@ sigproc_printf ("ReleaseSemaphore succeeded");
sip_printf ("Waiting for thiscomplete %p", thiscomplete); sip_printf ("Waiting for thiscomplete %p", thiscomplete);
SetLastError (0); SetLastError (0);
Sleep (0);
rc = WaitForSingleObject (thiscomplete, WSSC); rc = WaitForSingleObject (thiscomplete, WSSC);
/* Check for strangeness due to this thread being redirected by the /* Check for strangeness due to this thread being redirected by the
signal handler. Sometimes a WAIT_TIMEOUT will occur when the signal handler. Sometimes a WAIT_TIMEOUT will occur when the