* cygthread.h (cygthread::stack_ptr): New element.
(cygthread::detach): Accept a "wait_for_signal" argument. (cygthread::terminate_thread): New function. * cygthread.cc (cygthread::stub): Set stack pointer argument. (cygthread::terminate_thread): New function. Forcibly terminate thread. (cygthread::detach): Optionally wait for signals and kill thread when signal arrives. * exceptions.cc (signal_exit): Set signal_arrived prior to exiting to wake up anything blocking on signals. * fhandler.h (fhandler_base::set_r_no_interrupt): Change to accept bool argument. (fhandler_pipe::ready_for_read): Declare. * pipe.cc (pipeargs): New structure. (read_pipe): New thread stub wrapper for normal pipe read. (fhandler_pipe::read): Modify to call reader in a cygthread, terminating on signal, as appropriate. * select.cc (fhandler_pipe::ready_for_read): Define new function.
This commit is contained in:
@@ -22,6 +22,7 @@ details. */
|
||||
#include "cygheap.h"
|
||||
#include "thread.h"
|
||||
#include "pinfo.h"
|
||||
#include "cygthread.h"
|
||||
|
||||
static unsigned pipecount;
|
||||
static const NO_COPY char pipeid_fmt[] = "stupid_pipe.%u.%u";
|
||||
@@ -50,14 +51,36 @@ fhandler_pipe::set_close_on_exec (int val)
|
||||
set_inheritance (writepipe_exists, val);
|
||||
}
|
||||
|
||||
struct pipeargs
|
||||
{
|
||||
fhandler_base *fh;
|
||||
void *ptr;
|
||||
size_t len;
|
||||
int res;
|
||||
};
|
||||
|
||||
static DWORD WINAPI
|
||||
read_pipe (void *arg)
|
||||
{
|
||||
pipeargs *pi = (pipeargs *) arg;
|
||||
pi->res = pi->fh->fhandler_base::read (pi->ptr, pi->len);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int __stdcall
|
||||
fhandler_pipe::read (void *in_ptr, size_t in_len)
|
||||
{
|
||||
if (broken_pipe)
|
||||
return 0;
|
||||
int res = this->fhandler_base::read (in_ptr, in_len);
|
||||
pipeargs pi;
|
||||
pi.fh = this;
|
||||
pi.ptr = in_ptr;
|
||||
pi.len = in_len;
|
||||
pi.res = -1;
|
||||
cygthread *th = new cygthread (read_pipe, &pi, "read_pipe");
|
||||
th->detach (1);
|
||||
(void) ReleaseMutex (guard);
|
||||
return res;
|
||||
return pi.res;
|
||||
}
|
||||
|
||||
int fhandler_pipe::close ()
|
||||
|
Reference in New Issue
Block a user