mirror of
https://github.com/troglobit/finit.git
synced 2026-10-01 05:22:48 +07:00
Drop SIGSTOP/TSTP/CONT handlers, not needed anymore
Once upon a time, SIGSTOP was used to pause Finit during flashing (MTD) of a system image. This to prevent Finit from accidentally starting any programs, i.e., reading from flash disk during or after upgrade. This was quite intrusive, and has possible nasty side effects, e.g., any process with root access sends SIGSTOP prevents TTY login. So this patch now removes the functionality and recommends using a dedcicated runlevel for such critical tasks instead. Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
+1
-10
@@ -301,29 +301,20 @@ static int activate_console(int noclear, int nowait)
|
||||
tcsetattr(STDIN_FILENO, TCSAFLUSH, &c);
|
||||
}
|
||||
|
||||
while (!fexist(SYNC_SHUTDOWN)) {
|
||||
if (!fexist(SYNC_SHUTDOWN)) {
|
||||
char c;
|
||||
static const char clr[] = "\r\e[2K";
|
||||
static const char cup[] = "\e[A";
|
||||
static const char msg[] = "\nPlease press Enter to activate this console.";
|
||||
|
||||
if (fexist(SYNC_STOPPED)) {
|
||||
sleep(5);
|
||||
continue;
|
||||
}
|
||||
|
||||
dprint(STDERR_FILENO, clr, strlen(clr));
|
||||
dprint(STDERR_FILENO, msg, strlen(msg));
|
||||
while (read(STDIN_FILENO, &c, 1) == 1 && c != '\r')
|
||||
continue;
|
||||
|
||||
if (fexist(SYNC_STOPPED))
|
||||
continue;
|
||||
|
||||
dprint(STDERR_FILENO, clr, strlen(clr));
|
||||
dprint(STDERR_FILENO, cup, strlen(cup));
|
||||
ret = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Restore TTY */
|
||||
|
||||
+1
-2
@@ -347,8 +347,7 @@ static void source_env(svc_t *svc)
|
||||
|
||||
static int is_norespawn(void)
|
||||
{
|
||||
return sig_stopped() ||
|
||||
fexist("/mnt/norespawn") ||
|
||||
return fexist("/mnt/norespawn") ||
|
||||
fexist("/tmp/norespawn");
|
||||
}
|
||||
|
||||
|
||||
@@ -96,11 +96,9 @@ extern svc_t *wdog;
|
||||
*/
|
||||
shutop_t halt = SHUT_DEFAULT;
|
||||
|
||||
static int stopped = 0;
|
||||
static uev_t sigterm_watcher, sigusr1_watcher, sigusr2_watcher;
|
||||
static uev_t sighup_watcher, sigint_watcher, sigpwr_watcher;
|
||||
static uev_t sigchld_watcher;
|
||||
static uev_t sigstop_watcher, sigtstp_watcher, sigcont_watcher;
|
||||
|
||||
static struct sigmap {
|
||||
int num;
|
||||
@@ -416,42 +414,6 @@ static void sigchld_cb(uev_t *w, void *arg, int events)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* SIGSTOP/SIGTSTP: Paused by user or netflash
|
||||
*/
|
||||
static void sigstop_cb(uev_t *w, void *arg, int events)
|
||||
{
|
||||
if (UEV_ERROR == events) {
|
||||
_e("Unrecoverable error in signal watcher");
|
||||
return;
|
||||
}
|
||||
|
||||
touch(SYNC_STOPPED);
|
||||
stopped++;
|
||||
}
|
||||
|
||||
/*
|
||||
* SIGCONT: Restart service monitor
|
||||
*/
|
||||
static void sigcont_cb(uev_t *w, void *arg, int events)
|
||||
{
|
||||
if (UEV_ERROR == events) {
|
||||
_e("Unrecoverable error in signal watcher");
|
||||
return;
|
||||
}
|
||||
|
||||
stopped = 0;
|
||||
erase(SYNC_STOPPED);
|
||||
}
|
||||
|
||||
/*
|
||||
* Is SIGSTOP asserted?
|
||||
*/
|
||||
int sig_stopped(void)
|
||||
{
|
||||
return stopped;
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert SIGFOO to a number, if it exists
|
||||
*/
|
||||
@@ -541,7 +503,6 @@ void sig_setup(uev_ctx_t *ctx)
|
||||
|
||||
/* Cleanup any stale finit control files */
|
||||
erase(SYNC_SHUTDOWN);
|
||||
erase(SYNC_STOPPED);
|
||||
|
||||
/*
|
||||
* Standard SysV init calls ctrl-alt-delete handler
|
||||
@@ -565,11 +526,6 @@ void sig_setup(uev_ctx_t *ctx)
|
||||
/* After initial bootstrap of Finit we call the service monitor to reap children */
|
||||
uev_signal_init(ctx, &sigchld_watcher, sigchld_cb, NULL, SIGCHLD);
|
||||
|
||||
/* Stopping init is a bit tricky. */
|
||||
uev_signal_init(ctx, &sigstop_watcher, sigstop_cb, NULL, SIGSTOP);
|
||||
uev_signal_init(ctx, &sigtstp_watcher, sigstop_cb, NULL, SIGTSTP);
|
||||
uev_signal_init(ctx, &sigcont_watcher, sigcont_cb, NULL, SIGCONT);
|
||||
|
||||
setsid();
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,6 @@
|
||||
#include <uev/uev.h>
|
||||
|
||||
#define SYNC_SHUTDOWN "/var/run/finit/.shutdown"
|
||||
#define SYNC_STOPPED "/var/run/finit/.stopped"
|
||||
|
||||
#define SETSIG(sa, sig, fun, flags) \
|
||||
do { \
|
||||
@@ -69,7 +68,6 @@ typedef enum {
|
||||
extern shutop_t halt;
|
||||
|
||||
void do_shutdown (shutop_t op);
|
||||
int sig_stopped (void);
|
||||
int sig_num (const char *name);
|
||||
void sig_init (void);
|
||||
void sig_unblock (void);
|
||||
|
||||
Reference in New Issue
Block a user