* 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:
parent
1e8b88023c
commit
774ea16211
@ -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>
|
||||
|
||||
* sigproc.cc: Set wait_sig priority to normal.
|
||||
|
@ -137,8 +137,13 @@ fhandler_console::read (void *pv, size_t buflen)
|
||||
DWORD nwait;
|
||||
|
||||
w4[0] = h;
|
||||
nwait = 2;
|
||||
if (iscygthread ())
|
||||
nwait = 1;
|
||||
else
|
||||
{
|
||||
w4[1] = signal_arrived;
|
||||
nwait = 2;
|
||||
}
|
||||
|
||||
for (;;)
|
||||
{
|
||||
@ -151,7 +156,6 @@ fhandler_console::read (void *pv, size_t buflen)
|
||||
case WAIT_OBJECT_0:
|
||||
break;
|
||||
case WAIT_OBJECT_0 + 1:
|
||||
if (!iscygthread ())
|
||||
set_sig_errno (EINTR);
|
||||
return -1;
|
||||
default:
|
||||
|
@ -154,7 +154,8 @@ void
|
||||
fhandler_pty_master::doecho (const void *str, DWORD len)
|
||||
{
|
||||
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);
|
||||
release_output_mutex ();
|
||||
}
|
||||
@ -219,12 +220,13 @@ fhandler_pty_master::process_slave_output (char *buf, size_t len)
|
||||
char outbuf[OUT_BUFFER_SIZE];
|
||||
DWORD n;
|
||||
int column = 0;
|
||||
|
||||
again:
|
||||
int rc = 0;
|
||||
|
||||
if (len == 0)
|
||||
return 0;
|
||||
goto out;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
if (neednl_)
|
||||
{
|
||||
/* We need to return a left over \n character, resulting from
|
||||
@ -233,7 +235,8 @@ again:
|
||||
don't check again here. */
|
||||
buf[0] = '\n';
|
||||
neednl_ = 0;
|
||||
return 1;
|
||||
rc = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
/* 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
|
||||
else seems to work completely. Windows should provide some sort
|
||||
of overlapped I/O for pipes, or something, but it doesn't. */
|
||||
DWORD avail;
|
||||
while (1)
|
||||
{
|
||||
if (! PeekNamedPipe (handle, NULL, 0, NULL, &avail, NULL))
|
||||
{
|
||||
if (GetLastError () == ERROR_BROKEN_PIPE)
|
||||
return 0;
|
||||
__seterrno ();
|
||||
return -1;
|
||||
}
|
||||
DWORD avail;
|
||||
if (!PeekNamedPipe (handle, NULL, 0, NULL, &avail, NULL))
|
||||
goto err;
|
||||
if (avail > 0)
|
||||
break;
|
||||
if (hit_eof ())
|
||||
return 0;
|
||||
goto out;
|
||||
Sleep (10);
|
||||
}
|
||||
|
||||
if (ReadFile (handle, outbuf, rlen, &n, NULL) == FALSE)
|
||||
{
|
||||
if (GetLastError () == ERROR_BROKEN_PIPE)
|
||||
return 0;
|
||||
__seterrno ();
|
||||
return -1;
|
||||
}
|
||||
goto err;
|
||||
|
||||
termios_printf ("len=%u", n);
|
||||
termios_printf ("rlen %u", n);
|
||||
|
||||
if (get_ttyp ()->ti.c_lflag & FLUSHO)
|
||||
{
|
||||
get_ttyp ()->write_retval = n;
|
||||
if (output_done_event != NULL)
|
||||
SetEvent (output_done_event);
|
||||
goto again;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (get_ttyp ()->OutputStopped)
|
||||
{
|
||||
termios_printf ("waiting for restart_output_event");
|
||||
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;
|
||||
|
||||
@ -341,13 +340,24 @@ again:
|
||||
|
||||
*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);
|
||||
return n;
|
||||
__seterrno ();
|
||||
rc = -1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
out:
|
||||
termios_printf ("returning %d", rc);
|
||||
return rc;
|
||||
}
|
||||
|
||||
static DWORD WINAPI
|
||||
@ -546,8 +556,10 @@ fhandler_tty_slave::write (const void *ptr, size_t len)
|
||||
|
||||
if (output_done_event != NULL)
|
||||
{
|
||||
termios_printf("tty%d waiting for output_done", ttynum);
|
||||
WaitForSingleObject (output_done_event, n * 1000);
|
||||
DWORD rc;
|
||||
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)
|
||||
|
@ -826,7 +826,6 @@ sigproc_printf ("ReleaseSemaphore succeeded");
|
||||
sip_printf ("Waiting for thiscomplete %p", thiscomplete);
|
||||
|
||||
SetLastError (0);
|
||||
Sleep (0);
|
||||
rc = WaitForSingleObject (thiscomplete, WSSC);
|
||||
/* Check for strangeness due to this thread being redirected by the
|
||||
signal handler. Sometimes a WAIT_TIMEOUT will occur when the
|
||||
|
Loading…
x
Reference in New Issue
Block a user