aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2003-07-22 09:48:56 +0000
committerEric Andersen <andersen@codepoet.org>2003-07-22 09:48:56 +0000
commit6fd0e31e872b366231bf0c9de1a0bafdd738a78e (patch)
treef7dff3d37a07c40cfe028a67e97ff1035abbd7e6
parent0246222351a8787e2e726c2526d795440893859c (diff)
downloadbusybox-6fd0e31e872b366231bf0c9de1a0bafdd738a78e.tar.gz
Patch from Andrew Flegg:
Here's a pretty crude patch to reload /etc/inittab when init receives a SIGHUP. The mailing list archives weren't entirely clear on whether or not it should already happen, but didn't appear to be. The patch: * Adds a new function, reload_signal() which just calls parse_inittab() and run_actions(RESPAWN) * Before entering the while (1) loop set up SIGHUP to call reload_signal() * Modify new_init_action to skip the action if the same command already exists on the same terminal This last bit means that changing already running entries is a bit hairy as you can end up with, for example, two shells running on the same virtual console. However, for solely adding/removing entries this patch seems to work quite well.
-rw-r--r--init/init.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/init/init.c b/init/init.c
index 1f0bd4aec..657bad6cd 100644
--- a/init/init.c
+++ b/init/init.c
@@ -847,7 +847,14 @@ static void new_init_action(int action, char *command, const char *cons)
}
/* Append to the end of the list */
- for (a = init_action_list; a && a->next; a = a->next);
+ for (a = init_action_list; a && a->next; a = a->next) {
+ /* don't enter action if it's already in the list */
+ if ((strcmp(a->command, command) == 0) &&
+ (strcmp(a->terminal, cons) ==0)) {
+ free(new_action);
+ return;
+ }
+ }
if (a) {
a->next = new_action;
} else {
@@ -1022,7 +1029,14 @@ static void parse_inittab(void)
#endif /* CONFIG_FEATURE_USE_INITTAB */
}
-
+static void reload_signal(int sig)
+{
+ message(LOG, "Reloading /etc/inittab");
+ parse_inittab();
+ run_actions(RESPAWN);
+ return;
+}
+
extern int init_main(int argc, char **argv)
{
struct init_action *a;
@@ -1120,6 +1134,9 @@ extern int init_main(int argc, char **argv)
loop_forever();
}
+ /* Redefine SIGHUP to reread /etc/inittab */
+ signal(SIGHUP, reload_signal);
+
/* Now run the looping stuff for the rest of forever */
while (1) {
/* run the respawn stuff */