Revision
23086
Author
zarzycki@apple.com
Date
2007-02-19 10:04:45 -0800 (Mon, 19 Feb 2007)

Log Message

<rdar://problem/4921877> launchd to terminate BootCache directly

Modified Paths

Diff

Modified: trunk/launchd/src/launchctl.c (23085 => 23086)


--- trunk/launchd/src/launchctl.c	2007-02-19 17:37:12 UTC (rev 23085)
+++ trunk/launchd/src/launchctl.c	2007-02-19 18:04:45 UTC (rev 23086)
@@ -1239,11 +1239,14 @@
 static void
 very_pid2_specific_bootstrap(bool sflag)
 {
+	struct timeval tvs, tve, tvd;
 	int hnmib[] = { CTL_KERN, KERN_HOSTNAME };
 	struct group *tfp_gr;
 
 	do_single_user_mode(sflag);
 
+	assumes(gettimeofday(&tvs, NULL) != -1);
+
 	if (assumes((tfp_gr = getgrnam("procview")) != NULL)) {
 		int tfp_r_mib[3] = { CTL_KERN, KERN_TFP, KERN_TFP_READ_GROUP };
 		gid_t tfp_r_gid = tfp_gr->gr_gid;
@@ -1335,6 +1338,20 @@
 	do_bootroot_magic();
 
 	_vproc_set_global_on_demand(false);
+
+	assumes(gettimeofday(&tve, NULL) != -1);
+
+	timersub(&tve, &tvs, &tvd);
+
+	if (!path_check("/System/Library/LoginPlugins/BootCache.loginPlugin")) {
+		int remaining_sec = 60 - tvd.tv_sec;
+		if (remaining_sec > 0) {
+			sleep(remaining_sec);
+		}
+
+		const char *bcc_stop_tool[] = { "BootCacheControl", "stop", NULL };
+		assumes(fwexec(bcc_stop_tool, true) != -1);
+	}
 }
 
 int