[BusyBox] init blocks signals and forgets to clear signal mask before executing news processes
Vladimir N. Oleynik
dzo at simtreas.ru
Fri Oct 3 13:03:28 UTC 2003
Jean,
> init blocks signals (especially SIGHUP) and forgets to clear the
> signal mask before calling execve. Therefore new processes never see
> SIGHUP if they don't unblock it themself.
>
> init_main:
>
> /* Set up sig handlers -- be sure to
> * clear all of these in run() */
> sigemptyset(&mask);
> sigaddset(&mask, SIGHUP);
> sigprocmask(SIG_BLOCK, &mask, NULL);
>
> But there is no code in run clearing this procmask. As a temporary
> workaround I have added the following:
>
> --- init.c 9 Sep 2003 21:36:47 -0000 1.2
> +++ init.c 21 Sep 2003 20:24:21 -0000 1.3
> @@ -602,6 +602,8 @@
>
> /* Now run it. The new program will take over this PID,
> * so nothing further in init.c should be run. */
> + sigemptyset(&omask);
> + sigprocmask(SIG_SETMASK, &omask, NULL);
> execv(cmdpath, cmd);
I not found documentation from man pages for this and lookup from kernel source: ;-)
from fs/exec.c
/*
* This function makes sure the current process has its own signal table,
* so that flush_signal_handlers can later reset the handlers without
*/
from kernel/signal.c
flush_signal_handlers(struct task_struct *t)
{
int i;
struct k_sigaction *ka = &t->sig->action[0];
for (i = _NSIG ; i != 0 ; i--) {
if (ka->sa.sa_handler != SIG_IGN)
ka->sa.sa_handler = SIG_DFL;
ka->sa.sa_flags = 0;
sigemptyset(&ka->sa.sa_mask);
ka++;
}
}
So. After exec() all signal unblocked. This is good right.
Also. This init.c part code have full equivalent sysvinit package.
You have really problem?
--w
vodz
More information about the busybox
mailing list