From 6fcb2238583e71dc3a4fb88eec43de85c5c074eb Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Fri, 29 Mar 2013 13:18:25 +0000 Subject: [PATCH] * sigproc.cc (wait_sig): Avoid uninitialized use of nb when retrying. Consolidate two error messages into one. --- winsup/cygwin/ChangeLog | 7 ++++++- winsup/cygwin/sigproc.cc | 21 +++++---------------- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 1ccbcf1ef..589b1a1ed 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,9 +1,14 @@ +2013-03-29 Christopher Faylor + + * sigproc.cc (wait_sig): Avoid uninitialized use of nb when retrying. + Consolidate two error messages into one. + 2013-03-28 Christopher Faylor * sigproc.cc (pending_signals::retry): Declare new element. (pending_signals::pending): Force an additional loop through wait_sig by setting retry whenever this function is called. - (sig_send): Reorganize to wait for SIGHOLD at bottom. Always add + (wait_sig): Reorganize to wait for SIGHOLD at bottom. Always add signal to pending queue and work on whole queue rather than just the one signal. Loop when sigq.retry is set. Fix long-broken check for SIGCHLD after queued signals. diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc index a38ff0251..015cbaf2b 100644 --- a/winsup/cygwin/sigproc.cc +++ b/winsup/cygwin/sigproc.cc @@ -1288,27 +1288,16 @@ wait_sig (VOID *) DWORD nb; sigpacket pack = {}; if (sigq.retry) - { - sigq.retry = false; - pack.si.si_signo = __SIGFLUSH; - } + pack.si.si_signo = __SIGFLUSH; else if (!ReadFile (my_readsig, &pack, sizeof (pack), &nb, NULL)) - Sleep (INFINITE); /* Never exit this thread */ - if (nb != sizeof (pack)) + Sleep (INFINITE); /* Assume were exiting. Never exit this thread */ + else if (nb != sizeof (pack) || !pack.si.si_signo) { - system_printf ("short read from signal pipe: %d != %d", nb, - sizeof (pack)); - continue; - } - - if (!pack.si.si_signo) - { -#ifdef DEBUGGING - system_printf ("zero signal?"); -#endif + system_printf ("garbled signal pipe data nb %u, sig %d", nb, pack.si.si_signo); continue; } + sigq.retry = false; /* Don't process signals when we start exiting */ if (exit_state > ES_EXIT_STARTING && pack.si.si_signo > 0) continue;