diff options
author | Christopher Faylor <me@cgf.cx> | 2002-12-14 04:01:32 +0000 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2002-12-14 04:01:32 +0000 |
commit | 8bce0d723c50924b908dca1467037c8008e872be (patch) | |
tree | dcaf982175c090c0e7668af5fa00dac09fb07b27 /winsup/cygwin/fhandler_console.cc | |
parent | ec085641a9b4d25e16df12d7449f7ad689934117 (diff) | |
download | cygnal-8bce0d723c50924b908dca1467037c8008e872be.tar.gz cygnal-8bce0d723c50924b908dca1467037c8008e872be.tar.bz2 cygnal-8bce0d723c50924b908dca1467037c8008e872be.zip |
Throughout, change fhandler_*::read and fhandler_*::raw_read to void functions
whose second arguments are both the lenght and the return value.
* fhandler.cc (fhandler_base::read): Rework slightly to use second argument as
input/output. Tweak CRLF stuff.
(fhandler_base::readv): Accommodate fhandler_*::read changes.
* cygthread.h (cygthread::detach): Declare as taking optional handle argument.
(cygthread::detach): When given a handle argument, wait for the handle to be
signalled before waiting for thread to detach. Return true when signal
detected.
Diffstat (limited to 'winsup/cygwin/fhandler_console.cc')
-rw-r--r-- | winsup/cygwin/fhandler_console.cc | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/winsup/cygwin/fhandler_console.cc b/winsup/cygwin/fhandler_console.cc index a7b13c6b9..96ef4284f 100644 --- a/winsup/cygwin/fhandler_console.cc +++ b/winsup/cygwin/fhandler_console.cc @@ -216,8 +216,8 @@ fhandler_console::send_winch_maybe () tc->kill_pgrp (SIGWINCH); } -int __stdcall -fhandler_console::read (void *pv, size_t buflen) +void __stdcall +fhandler_console::read (void *pv, size_t& buflen) { HANDLE h = get_io_handle (); @@ -229,7 +229,10 @@ fhandler_console::read (void *pv, size_t buflen) int copied_chars = get_readahead_into_buffer (buf, buflen); if (copied_chars) - return copied_chars; + { + buflen = copied_chars; + return; + } HANDLE w4[2]; DWORD nwait; @@ -248,7 +251,10 @@ fhandler_console::read (void *pv, size_t buflen) { int bgres; if ((bgres = bg_check (SIGTTIN)) <= bg_eof) - return bgres; + { + buflen = bgres; + return; + } set_cursor_maybe (); /* to make cursor appear on the screen immediately */ switch (WaitForMultipleObjects (nwait, w4, FALSE, INFINITE)) @@ -258,8 +264,7 @@ fhandler_console::read (void *pv, size_t buflen) case WAIT_OBJECT_0 + 1: goto sig_exit; default: - __seterrno (); - return -1; + goto err; } DWORD nread; @@ -268,9 +273,8 @@ fhandler_console::read (void *pv, size_t buflen) if (!ReadConsoleInput (h, &input_rec, 1, &nread)) { - __seterrno (); syscall_printf ("ReadConsoleInput failed, %E"); - return -1; /* seems to be failure */ + goto err; /* seems to be failure */ } /* check the event that occurred */ @@ -476,11 +480,18 @@ fhandler_console::read (void *pv, size_t buflen) } #undef buf - return copied_chars; + buflen = copied_chars; + return; + +err: + __seterrno (); + (ssize_t) buflen = -1; + return; sig_exit: set_sig_errno (EINTR); - return -1; + (ssize_t) buflen = -1; + return; } void |