diff options
author | Eric Andersen <andersen@codepoet.org> | 2003-07-22 09:48:56 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2003-07-22 09:48:56 +0000 |
commit | 6fd0e31e872b366231bf0c9de1a0bafdd738a78e (patch) | |
tree | f7dff3d37a07c40cfe028a67e97ff1035abbd7e6 | |
parent | 0246222351a8787e2e726c2526d795440893859c (diff) | |
download | busybox-w32-6fd0e31e872b366231bf0c9de1a0bafdd738a78e.tar.gz busybox-w32-6fd0e31e872b366231bf0c9de1a0bafdd738a78e.tar.bz2 busybox-w32-6fd0e31e872b366231bf0c9de1a0bafdd738a78e.zip |
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.c | 21 |
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) | |||
847 | } | 847 | } |
848 | 848 | ||
849 | /* Append to the end of the list */ | 849 | /* Append to the end of the list */ |
850 | for (a = init_action_list; a && a->next; a = a->next); | 850 | for (a = init_action_list; a && a->next; a = a->next) { |
851 | /* don't enter action if it's already in the list */ | ||
852 | if ((strcmp(a->command, command) == 0) && | ||
853 | (strcmp(a->terminal, cons) ==0)) { | ||
854 | free(new_action); | ||
855 | return; | ||
856 | } | ||
857 | } | ||
851 | if (a) { | 858 | if (a) { |
852 | a->next = new_action; | 859 | a->next = new_action; |
853 | } else { | 860 | } else { |
@@ -1022,7 +1029,14 @@ static void parse_inittab(void) | |||
1022 | #endif /* CONFIG_FEATURE_USE_INITTAB */ | 1029 | #endif /* CONFIG_FEATURE_USE_INITTAB */ |
1023 | } | 1030 | } |
1024 | 1031 | ||
1025 | 1032 | static void reload_signal(int sig) | |
1033 | { | ||
1034 | message(LOG, "Reloading /etc/inittab"); | ||
1035 | parse_inittab(); | ||
1036 | run_actions(RESPAWN); | ||
1037 | return; | ||
1038 | } | ||
1039 | |||
1026 | extern int init_main(int argc, char **argv) | 1040 | extern int init_main(int argc, char **argv) |
1027 | { | 1041 | { |
1028 | struct init_action *a; | 1042 | struct init_action *a; |
@@ -1120,6 +1134,9 @@ extern int init_main(int argc, char **argv) | |||
1120 | loop_forever(); | 1134 | loop_forever(); |
1121 | } | 1135 | } |
1122 | 1136 | ||
1137 | /* Redefine SIGHUP to reread /etc/inittab */ | ||
1138 | signal(SIGHUP, reload_signal); | ||
1139 | |||
1123 | /* Now run the looping stuff for the rest of forever */ | 1140 | /* Now run the looping stuff for the rest of forever */ |
1124 | while (1) { | 1141 | while (1) { |
1125 | /* run the respawn stuff */ | 1142 | /* run the respawn stuff */ |