diff options
author | Paulius Zaleckas <paulius.zaleckas@gmail.com> | 2013-08-16 12:01:58 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2013-08-16 12:01:58 +0200 |
commit | 9f07af6156267f1e3064c14f2bee96560f7ed69d (patch) | |
tree | 44a3a282fefdb93c2a88df1af185d9b01c91914e | |
parent | d2e07bc16cbd68bc2771f9f163e610e4e327c67c (diff) | |
download | busybox-9f07af6156267f1e3064c14f2bee96560f7ed69d.tar.gz |
init: don't srop unterminated processes' entries during inittab reload
This feature was removed in 72c99af
It is useful when process is removed from inittab and later added
back, but never terminated. It prevents init from spawning duplicate.
function old new delta
check_delayed_sigs 176 182 +6
Signed-off-by: Paulius Zaleckas <paulius.zaleckas@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | init/init.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/init/init.c b/init/init.c index 05ed4f7a7..edb5be696 100644 --- a/init/init.c +++ b/init/init.c @@ -638,7 +638,7 @@ static void new_init_action(uint8_t action_type, const char *command, const char a->action_type = action_type; strcpy(a->command, command); safe_strncpy(a->terminal, cons, sizeof(a->terminal)); - dbg_message(L_LOG | L_CONSOLE, "command='%s' action=%d tty='%s'\n", + dbg_message(L_LOG | L_CONSOLE, "command='%s' action=%x tty='%s'\n", a->command, a->action_type, a->terminal); } @@ -934,10 +934,17 @@ static void reload_inittab(void) /* Remove stale entries and SYSINIT entries. * We never rerun SYSINIT entries anyway, - * removing them too saves a few bytes */ + * removing them too saves a few bytes + */ nextp = &init_action_list; while ((a = *nextp) != NULL) { - if ((a->action_type & ~SYSINIT) == 0) { + /* + * Why pid == 0 check? + * Process can be removed from inittab and added *later*. + * If we delete its entry but process still runs, + * duplicate is spawned when the entry is re-added. + */ + if ((a->action_type & ~SYSINIT) == 0 && a->pid == 0) { *nextp = a->next; free(a); } else { |