mirror of
https://github.com/troglobit/finit.git
synced 2026-10-15 10:29:35 +00:00
Unblock all signals blocked by finit when starting children
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
425cd17e57
commit
e0529a5597
3 files changed
+29
-9
No files matched your search
@@ -466,7 +466,9 @@ int run(char *cmd)
|
||||
dup2(fd, STDERR_FILENO);
|
||||
}
|
||||
|
||||
sig_unblock();
|
||||
execvp(args[0], args);
|
||||
|
||||
_exit(1); /* Only if execv() fails. */
|
||||
} else if (-1 == pid) {
|
||||
_pe("%s", args[0]);
|
||||
@@ -566,10 +568,8 @@ pid_t run_getty(char *cmd, char *args[], int console)
|
||||
pid_t pid = vfork();
|
||||
|
||||
if (!pid) {
|
||||
int i, fd;
|
||||
int fd;
|
||||
char c;
|
||||
sigset_t nmask;
|
||||
struct sigaction sa;
|
||||
|
||||
if (console) {
|
||||
/* Detach from initial controlling TTY */
|
||||
@@ -590,13 +590,8 @@ pid_t run_getty(char *cmd, char *args[], int console)
|
||||
|
||||
prctl(PR_SET_NAME, "console", 0, 0, 0);
|
||||
}
|
||||
sigemptyset(&nmask);
|
||||
sigaddset(&nmask, SIGCHLD);
|
||||
sigprocmask(SIG_UNBLOCK, &nmask, NULL);
|
||||
|
||||
/* Reset signal handlers that were set by the parent process */
|
||||
for (i = 1; i < NSIG; i++)
|
||||
DFLSIG(sa, i, 0);
|
||||
sig_unblock();
|
||||
|
||||
while (!fexist(SYNC_SHUTDOWN)) {
|
||||
static const char msg[] = "\nPlease press Enter to activate this console.";
|
||||
@@ -672,6 +667,7 @@ int run_parts(char *dir, char *cmd)
|
||||
pid = vfork();
|
||||
if (!pid) {
|
||||
_d("Calling %s ...", path);
|
||||
sig_unblock();
|
||||
execv(path, args);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
@@ -148,6 +148,29 @@ void sig_init(void)
|
||||
SETSIG(sa, SIGCHLD, chld_handler, SA_RESTART);
|
||||
}
|
||||
|
||||
/*
|
||||
* Unblock all signals blocked by finit when starting children
|
||||
*/
|
||||
void sig_unblock(void)
|
||||
{
|
||||
int i;
|
||||
sigset_t nmask;
|
||||
struct sigaction sa;
|
||||
|
||||
sigemptyset(&nmask);
|
||||
sigaddset(&nmask, SIGCHLD);
|
||||
sigaddset(&nmask, SIGINT);
|
||||
sigaddset(&nmask, SIGPWR);
|
||||
sigaddset(&nmask, SIGSTOP);
|
||||
sigaddset(&nmask, SIGTSTP);
|
||||
sigaddset(&nmask, SIGCONT);
|
||||
sigprocmask(SIG_UNBLOCK, &nmask, NULL);
|
||||
|
||||
/* Reset signal handlers that were set by the parent process */
|
||||
for (i = 1; i < NSIG; i++)
|
||||
DFLSIG(sa, i, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Setup limited set of SysV compatible signals to respond to
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user