* sigproc.h (wait_for_sigthread): Eliminate parameter.
* sigproc.cc (wait_for_sigthread): Ditto. Don't synchronize with wait_sig after receiving an event that it is ready to go. (init_sig_pipe): New function. (wait_sig): Call init_sig_pipe to create pipes for communicating signals to this process. Don't send sigCONT signal when initializing. * fork.cc (frok::child): Accommodate wait_for_sigpipe parameter change. * fhandler.h (fhandler_*::write): Make ssize_t/__stdcall. (fhandler_*::write_overlapped): Ditto. (fhandler_*::raw_write): Ditto. (fhandler_*::readv): Ditto. (fhandler_*::writev): Ditto. (fhandler_*::raw_read): Make __stdcall. * fhandler: Accommodate changes to read/write functions throughout. * fhandler_clipboard.cc: Ditto. * fhandler_console.cc: Ditto. * fhandler_dsp.cc: Ditto. * fhandler_fifo.cc: Ditto. * fhandler_mailslot.cc: Ditto. * fhandler_mem.cc: Ditto. * fhandler_mem.cc: Ditto. * fhandler_random.cc: Ditto. * fhandler_tape.cc: Ditto. * fhandler_tty.cc: Ditto. * fhandler_virtual.cc: Ditto. * fhandler_windows.cc: Ditto. * fhandler_zero.cc: Ditto. * syscalls.cc (readv): Use ssize_t as temp variable. * fhandler.cc (fhandler_base::read): Coerce returned len to signed or it will never be treated as < 0. (fhandler_base::wait_overlapped): Minimize calls to GetLastError. Remove duplicate debugging test. Fix error return. * fhandler.h (fhandler_fifo::fifo_name): Declare new function. (fhandler_fifo::close): Ditto. (fhandler_fifo::dup): Ditto. (fhandler_fifo::close_on_exec): Ditto. * fhandler.cc (fhandler_fifo::fifo_name): Define new function. (FIFO_BUF_SIZE): New define. (cnp): Ditto. (fhandler_fifo::open): Rework. Use cnp to open named pipe. Always open write side as a client. Open dummy client when writing and can't connect. (wait): Rework. Implement fifo_wait_for_next_client. Handle signals during connect better. Add new fifo_wait_for_server code which polls (sigh) waiting for server. (fhandler_fifo::raw_read): Handle transition states when one client closes and another is available. (fhandler_fifo::close): Define. (fhandler_fifo::dup): Ditto. (fhandler_fifo::close_on_exec): Ditto.
This commit is contained in:
@ -128,24 +128,16 @@ signal_fixup_after_exec ()
|
||||
}
|
||||
|
||||
void __stdcall
|
||||
wait_for_sigthread (bool forked)
|
||||
wait_for_sigthread ()
|
||||
{
|
||||
char char_sa_buf[1024];
|
||||
PSECURITY_ATTRIBUTES sa_buf = sec_user_nih ((PSECURITY_ATTRIBUTES) char_sa_buf, cygheap->user.sid());
|
||||
if (!CreatePipe (&my_readsig, &my_sendsig, sa_buf, 0))
|
||||
api_fatal ("couldn't create signal pipe%s, %E", forked ? " for forked process" : "");
|
||||
ProtectHandle (my_readsig);
|
||||
myself->sendsig = my_sendsig;
|
||||
|
||||
myself->process_state |= PID_ACTIVE;
|
||||
myself->process_state &= ~PID_INITIALIZING;
|
||||
|
||||
sigproc_printf ("wait_sig_inited %p", wait_sig_inited);
|
||||
HANDLE hsig_inited = wait_sig_inited;
|
||||
WaitForSingleObject (hsig_inited, INFINITE);
|
||||
wait_sig_inited = NULL;
|
||||
myself->sendsig = my_sendsig;
|
||||
myself->process_state |= PID_ACTIVE;
|
||||
myself->process_state &= ~PID_INITIALIZING;
|
||||
ForceCloseHandle1 (hsig_inited, wait_sig_inited);
|
||||
SetEvent (sigCONT);
|
||||
sigproc_printf ("process/signal handling enabled, state %p", myself->process_state);
|
||||
}
|
||||
|
||||
@ -1152,11 +1144,28 @@ pending_signals::next ()
|
||||
return res;
|
||||
}
|
||||
|
||||
/* Called separately to allow stack space reutilization by wait_sig.
|
||||
This function relies on the fact that it will be called after cygheap
|
||||
has been set up. For the case of non-dynamic DLL initialization this
|
||||
means that it relies on the implicit serialization guarantted by being
|
||||
run as part of DLL_PROCESS_ATTACH. */
|
||||
static void __attribute__ ((noinline))
|
||||
init_sig_pipe()
|
||||
{
|
||||
char char_sa_buf[1024];
|
||||
PSECURITY_ATTRIBUTES sa_buf = sec_user_nih ((PSECURITY_ATTRIBUTES) char_sa_buf, cygheap->user.sid());
|
||||
if (!CreatePipe (&my_readsig, &my_sendsig, sa_buf, 0))
|
||||
api_fatal ("couldn't create signal pipe, %E");
|
||||
ProtectHandle (my_readsig);
|
||||
}
|
||||
|
||||
|
||||
/* Process signals by waiting for signal data to arrive in a pipe.
|
||||
Set a completion event if one was specified. */
|
||||
static DWORD WINAPI
|
||||
wait_sig (VOID *)
|
||||
{
|
||||
init_sig_pipe ();
|
||||
/* Initialization */
|
||||
SetThreadPriority (GetCurrentThread (), WAIT_SIG_PRIORITY);
|
||||
|
||||
@ -1169,7 +1178,7 @@ wait_sig (VOID *)
|
||||
my_readsig, my_sendsig);
|
||||
|
||||
sigpacket pack;
|
||||
pack.si.si_signo = __SIGHOLD;
|
||||
pack.si.si_signo = 0;
|
||||
for (;;)
|
||||
{
|
||||
if (pack.si.si_signo == __SIGHOLD)
|
||||
|
Reference in New Issue
Block a user