* fork.cc (fork): Honor error return from sig_send. Don't continue with fork

if we couldn't suspend signals.
* sigproc.cc (sig_send): Set sigCONT event when we see __SIGNOHOLD.
(wait_sig): Remove holding_signals.  Create pipe with a buffer which will
theoretically cause blocking if there is nothing reading on the pipe.  Wait for
sigCONT at end of loop when we have a __SIGHOLD.
This commit is contained in:
Christopher Faylor 2005-12-23 01:24:14 +00:00
parent 52792a770d
commit ede284de5f
3 changed files with 24 additions and 8 deletions

View File

@ -1,3 +1,12 @@
2005-12-22 Christopher Faylor <cgf@timesys.com>
* fork.cc (fork): Honor error return from sig_send. Don't continue
with fork if we couldn't suspend signals.
* sigproc.cc (sig_send): Set sigCONT event when we see __SIGNOHOLD.
(wait_sig): Remove holding_signals. Create pipe with a buffer which
will theoretically cause blocking if there is nothing reading on the
pipe. Wait for sigCONT at end of loop when we have a __SIGHOLD.
2005-12-22 Corinna Vinschen <corinna@vinschen.de> 2005-12-22 Corinna Vinschen <corinna@vinschen.de>
* fhandler.h (fhandler_base::issymlink): New method. * fhandler.h (fhandler_base::issymlink): New method.

View File

@ -507,7 +507,14 @@ fork ()
return -1; return -1;
} }
sig_send (NULL, __SIGHOLD); if (sig_send (NULL, __SIGHOLD))
{
if (exit_state)
Sleep (INFINITE);
set_errno (EAGAIN);
return -1;
}
ischild = setjmp (grouped.ch.jmp); ischild = setjmp (grouped.ch.jmp);
void *esp; void *esp;

View File

@ -509,6 +509,8 @@ sigproc_terminate (exit_states es)
int __stdcall int __stdcall
sig_send (_pinfo *p, int sig) sig_send (_pinfo *p, int sig)
{ {
if (sig == __SIGNOHOLD)
SetEvent (sigCONT);
siginfo_t si; siginfo_t si;
si.si_signo = sig; si.si_signo = sig;
si.si_code = SI_KERNEL; si.si_code = SI_KERNEL;
@ -1046,12 +1048,11 @@ wait_sig (VOID *)
{ {
HANDLE readsig; HANDLE readsig;
PSECURITY_ATTRIBUTES sa_buf = (PSECURITY_ATTRIBUTES) alloca (1024); PSECURITY_ATTRIBUTES sa_buf = (PSECURITY_ATTRIBUTES) alloca (1024);
Static bool holding_signals;
/* Initialization */ /* Initialization */
SetThreadPriority (GetCurrentThread (), WAIT_SIG_PRIORITY); SetThreadPriority (GetCurrentThread (), WAIT_SIG_PRIORITY);
if (!CreatePipe (&readsig, &myself->sendsig, sec_user_nih (sa_buf), 0)) if (!CreatePipe (&readsig, &myself->sendsig, sec_user_nih (sa_buf), sizeof (sigpacket) - 4))
api_fatal ("couldn't create signal pipe, %E"); api_fatal ("couldn't create signal pipe, %E");
ProtectHandle (readsig); ProtectHandle (readsig);
sigCONT = CreateEvent (&sec_none_nih, FALSE, FALSE, NULL); sigCONT = CreateEvent (&sec_none_nih, FALSE, FALSE, NULL);
@ -1121,11 +1122,9 @@ wait_sig (VOID *)
*pack.mask |= bit; *pack.mask |= bit;
break; break;
case __SIGHOLD: case __SIGHOLD:
holding_signals = 1; goto loop;
break; break;
case __SIGNOHOLD: case __SIGNOHOLD:
holding_signals = 0;
/* fall through, intentionally */
case __SIGFLUSH: case __SIGFLUSH:
case __SIGFLUSHFAST: case __SIGFLUSHFAST:
sigq.reset (); sigq.reset ();
@ -1144,8 +1143,6 @@ wait_sig (VOID *)
default: default:
if (pack.si.si_signo < 0) if (pack.si.si_signo < 0)
sig_clear (-pack.si.si_signo); sig_clear (-pack.si.si_signo);
else if (holding_signals)
sigq.add (pack);
else else
{ {
int sig = pack.si.si_signo; int sig = pack.si.si_signo;
@ -1173,11 +1170,14 @@ wait_sig (VOID *)
} }
if (clearwait) if (clearwait)
proc_subproc (PROC_CLEARWAIT, 0); proc_subproc (PROC_CLEARWAIT, 0);
loop:
if (pack.wakeup) if (pack.wakeup)
{ {
sigproc_printf ("signalling pack.wakeup %p", pack.wakeup); sigproc_printf ("signalling pack.wakeup %p", pack.wakeup);
SetEvent (pack.wakeup); SetEvent (pack.wakeup);
} }
if (pack.si.si_signo == __SIGHOLD)
WaitForSingleObject (sigCONT, INFINITE);
if (pack.si.si_signo == __SIGEXIT) if (pack.si.si_signo == __SIGEXIT)
break; break;
} }