[launchd-changes] [23041] trunk/launchd/src/launchd.c

source_changes at macosforge.org source_changes at macosforge.org
Wed Feb 7 17:28:03 PST 2007


Revision: 23041
          http://trac.macosforge.org/projects/launchd/changeset/23041
Author:   zarzycki at apple.com
Date:     2007-02-07 17:28:03 -0800 (Wed, 07 Feb 2007)

Log Message:
-----------
With this change, you can now: "sudo kill -TERM 1" and the machine will gracefully power off.

Modified Paths:
--------------
    trunk/launchd/src/launchd.c

Modified: trunk/launchd/src/launchd.c
===================================================================
--- trunk/launchd/src/launchd.c	2007-02-07 23:39:58 UTC (rev 23040)
+++ trunk/launchd/src/launchd.c	2007-02-08 01:28:03 UTC (rev 23041)
@@ -41,6 +41,7 @@
 #include <sys/ioctl.h>
 #include <sys/mount.h>
 #include <sys/kern_event.h>
+#include <sys/reboot.h>
 #include <net/if.h>
 #include <netinet/in.h>
 #include <netinet/in_var.h>
@@ -678,12 +679,14 @@
 	if (shutdown_in_progress && jobmgr_is_idle(root_jobmgr)) {
 		shutdown_in_progress = false;
 
-		if (getpid() != 1) {
+		if (getpid() == 1) {
+			if (re_exec_in_single_user_mode) {
+				kill(-1, SIGKILL); /* One last time, just to clear the room */
+				launchd_assumes(execl("/sbin/launchd", "/sbin/launchd", "-s", NULL) != -1);
+			}
+			launchd_assumes(reboot(RB_HALT) != -1);
+		} else {
 			exit(EXIT_SUCCESS);
-		} else if (re_exec_in_single_user_mode) {
-			re_exec_in_single_user_mode = false;
-			kill(-1, SIGKILL); /* One last time, just to clear the room */
-			launchd_assumes(execl("/sbin/launchd", "/sbin/launchd", "-s", NULL) != -1);
 		}
 	}
 	if (getpid() == 1) {

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070207/0ce0a957/attachment.html


More information about the launchd-changes mailing list