aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2009-11-15 03:07:19 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2009-11-15 03:07:19 +0100
commit6e54249e05f3fbe472814465d8f3e122801b7e96 (patch)
tree283fb0e9ef851c9d49892b4adec07bf26223ed02
parent72ac6901f436e9ce22ef68ff89c3830c8b5f3ef1 (diff)
downloadbusybox-w32-6e54249e05f3fbe472814465d8f3e122801b7e96.tar.gz
busybox-w32-6e54249e05f3fbe472814465d8f3e122801b7e96.tar.bz2
busybox-w32-6e54249e05f3fbe472814465d8f3e122801b7e96.zip
init: restore possibility to reload inittab even before we finish initialization
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--init/init.c34
1 files changed, 18 insertions, 16 deletions
diff --git a/init/init.c b/init/init.c
index 5240e47a5..14136859f 100644
--- a/init/init.c
+++ b/init/init.c
@@ -40,9 +40,9 @@
40#define ONCE 0x04 40#define ONCE 0x04
41/* 41/*
42 * NB: while SYSINIT/WAIT/ONCE are being processed, 42 * NB: while SYSINIT/WAIT/ONCE are being processed,
43 * SIGHUP ("reread /etc/inittab") will be ignored. 43 * SIGHUP ("reread /etc/inittab") will be processed only after
44 * Rationale: it would be ambiguous whether SYSINIT/WAIT/ONCE 44 * each group of actions. If new inittab adds, say, a SYSINIT action,
45 * need to be rerun or not. 45 * it will not be run, since init is already "past SYSINIT stage".
46 */ 46 */
47/* Start these after ONCE are started, restart on exit */ 47/* Start these after ONCE are started, restart on exit */
48#define RESPAWN 0x08 48#define RESPAWN 0x08
@@ -754,12 +754,12 @@ static void reload_inittab(void)
754 754
755 /* Disable old entries */ 755 /* Disable old entries */
756 for (a = init_action_list; a; a = a->next) 756 for (a = init_action_list; a; a = a->next)
757 a->action_type = ONCE; 757 a->action_type = 0;
758 758
759 /* Append new entries, or modify existing entries 759 /* Append new entries, or modify existing entries
760 * (set a->action_type) if cmd and device name 760 * (incl. setting a->action_type) if cmd and device name
761 * match new ones. End result: only entries with 761 * match new ones. End result: only entries with
762 * a->action_type == ONCE are stale. 762 * a->action_type == 0 are stale.
763 */ 763 */
764 parse_inittab(); 764 parse_inittab();
765 765
@@ -767,24 +767,26 @@ static void reload_inittab(void)
767 /* Kill stale entries */ 767 /* Kill stale entries */
768 /* Be nice and send SIGTERM first */ 768 /* Be nice and send SIGTERM first */
769 for (a = init_action_list; a; a = a->next) 769 for (a = init_action_list; a; a = a->next)
770 if (a->action_type == ONCE && a->pid != 0) 770 if (a->action_type == 0 && a->pid != 0)
771 kill(a->pid, SIGTERM); 771 kill(a->pid, SIGTERM);
772 if (CONFIG_FEATURE_KILL_DELAY) { 772 if (CONFIG_FEATURE_KILL_DELAY) {
773 /* NB: parent will wait in NOMMU case */ 773 /* NB: parent will wait in NOMMU case */
774 if ((BB_MMU ? fork() : vfork()) == 0) { /* child */ 774 if ((BB_MMU ? fork() : vfork()) == 0) { /* child */
775 sleep(CONFIG_FEATURE_KILL_DELAY); 775 sleep(CONFIG_FEATURE_KILL_DELAY);
776 for (a = init_action_list; a; a = a->next) 776 for (a = init_action_list; a; a = a->next)
777 if (a->action_type == ONCE && a->pid != 0) 777 if (a->action_type == 0 && a->pid != 0)
778 kill(a->pid, SIGKILL); 778 kill(a->pid, SIGKILL);
779 _exit(EXIT_SUCCESS); 779 _exit(EXIT_SUCCESS);
780 } 780 }
781 } 781 }
782#endif 782#endif
783 783
784 /* Remove stale (ONCE) and not useful (SYSINIT,WAIT) entries */ 784 /* Remove stale entries and SYSINIT entries.
785 * We never rerun SYSINIT entries anyway,
786 * removing them too saves a few bytes */
785 nextp = &init_action_list; 787 nextp = &init_action_list;
786 while ((a = *nextp) != NULL) { 788 while ((a = *nextp) != NULL) {
787 if (a->action_type & (ONCE | SYSINIT | WAIT)) { 789 if ((a->action_type & ~SYSINIT) == 0) {
788 *nextp = a->next; 790 *nextp = a->next;
789 free(a); 791 free(a);
790 } else { 792 } else {
@@ -943,6 +945,12 @@ int init_main(int argc UNUSED_PARAM, char **argv)
943 bb_signals_recursive_norestart((1 << SIGINT), record_signo); 945 bb_signals_recursive_norestart((1 << SIGINT), record_signo);
944 } 946 }
945 947
948 /* Set up "reread /etc/inittab" handler.
949 * Handler is set up without SA_RESTART, it will interrupt syscalls.
950 */
951 if (!DEBUG_INIT && ENABLE_FEATURE_USE_INITTAB)
952 bb_signals_recursive_norestart((1 << SIGHUP), record_signo);
953
946 /* Now run everything that needs to be run */ 954 /* Now run everything that needs to be run */
947 /* First run the sysinit command */ 955 /* First run the sysinit command */
948 run_actions(SYSINIT); 956 run_actions(SYSINIT);
@@ -953,12 +961,6 @@ int init_main(int argc UNUSED_PARAM, char **argv)
953 /* Next run anything to be run only once */ 961 /* Next run anything to be run only once */
954 run_actions(ONCE); 962 run_actions(ONCE);
955 963
956 /* Set up "reread /etc/inittab" handler.
957 * Handler is set up without SA_RESTART, it will interrupt syscalls.
958 */
959 if (!DEBUG_INIT && ENABLE_FEATURE_USE_INITTAB)
960 bb_signals_recursive_norestart((1 << SIGHUP), record_signo);
961
962 /* Now run the looping stuff for the rest of forever. 964 /* Now run the looping stuff for the rest of forever.
963 */ 965 */
964 while (1) { 966 while (1) {