[Initng-svn] r3196 - initng/trunk/src

svn at initng.thinktux.net svn at initng.thinktux.net
Sat Mar 4 23:45:05 CET 2006


Author: makomk
Date: Sat Mar  4 23:45:05 2006
New Revision: 3196

Modified:
   initng/trunk/src/initng_main.c
Log:
Partial fix for bug #488


Modified: initng/trunk/src/initng_main.c
==============================================================================
--- initng/trunk/src/initng_main.c	(original)
+++ initng/trunk/src/initng_main.c	Sat Mar  4 23:45:05 2006
@@ -131,7 +131,7 @@
 
 static void initng_hard(h_then t)
 {
-    FILE *test;
+    FILE *test; int pid;
 
     /* set the sys state */
     if (t == THEN_REBOOT)
@@ -166,11 +166,29 @@
         return;
     }
 
-    /* shut down the machine */
-    if (t == THEN_REBOOT)
-        reboot(RB_AUTOBOOT);
-    if (t == THEN_HALT)
-        reboot(RB_POWER_OFF);
+    if (t == THEN_REBOOT || t == THEN_HALT)
+    {
+        pid = fork();
+	if(pid == 0)
+	{
+	    /* child process - shut down the machine */
+	    if (t == THEN_REBOOT)
+	        reboot(RB_AUTOBOOT);
+	    if (t == THEN_HALT)
+ 	        reboot(RB_POWER_OFF);
+	    _exit(0);
+	} 
+	else if(pid < 0)
+	{
+	  F_("Failed to fork child process to reboot\n");
+	  return;
+	}
+	else 
+	{
+	    /* parent process waits for child to exit */
+	    waitpid(pid, NULL, 0);
+	}
+    }
 
     /* idle forever */
     while (1)


More information about the Initng-svn mailing list