[BusyBox-cvs] busybox/init init.c,1.189,1.190

Erik Andersen andersen at busybox.net
Tue Jul 22 09:49:00 UTC 2003


Update of /var/cvs/busybox/init
In directory winder:/tmp/cvs-serv29681/init

Modified Files:
	init.c 
Log Message:
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.



Index: init.c
===================================================================
RCS file: /var/cvs/busybox/init/init.c,v
retrieving revision 1.189
retrieving revision 1.190
diff -u -d -r1.189 -r1.190
--- init.c	22 Jul 2003 08:56:45 -0000	1.189
+++ init.c	22 Jul 2003 09:48:56 -0000	1.190
@@ -847,7 +847,14 @@
 	}
 
 	/* 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 @@
 #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;
@@ -1119,6 +1133,9 @@
 				"No more tasks for init -- sleeping forever.");
 		loop_forever();
 	}
+
+	/* Redefine SIGHUP to reread /etc/inittab */
+	signal(SIGHUP, reload_signal);
 
 	/* Now run the looping stuff for the rest of forever */
 	while (1) {




More information about the busybox-cvs mailing list