[launchd-changes] [23822] branches/PR-6562592/launchd/src/launchd_core_logic.c

source_changes at macosforge.org source_changes at macosforge.org
Wed Feb 18 11:25:29 PST 2009


Revision: 23822
          http://trac.macosforge.org/projects/launchd/changeset/23822
Author:   dsorresso at apple.com
Date:     2009-02-18 11:25:28 -0800 (Wed, 18 Feb 2009)
Log Message:
-----------
Now we're sending SIGTERM to strays and moving on. No waiting, and no followup SIGKILL.

Modified Paths:
--------------
    branches/PR-6562592/launchd/src/launchd_core_logic.c

Modified: branches/PR-6562592/launchd/src/launchd_core_logic.c
===================================================================
--- branches/PR-6562592/launchd/src/launchd_core_logic.c	2009-02-17 22:09:16 UTC (rev 23821)
+++ branches/PR-6562592/launchd/src/launchd_core_logic.c	2009-02-18 19:25:28 UTC (rev 23822)
@@ -5587,12 +5587,28 @@
 void
 jobmgr_kill_stray_children(jobmgr_t jm, pid_t *p, size_t np)
 {
+#if 1
+	/* I maintain that stray processes should be at the mercy of launchd during shutdown,
+	 * but nevertheless, things like diskimages-helper can stick around, and SIGKILLing 
+	 * them can result in data loss. So we send SIGTERM to all the strays and don't wait
+	 * for them to exit before moving on.
+	 * 
+	 * See rdar://problem/6562592
+	 */
+	size_t i = 0;
+	for( i = 0; i < np; i++ ) {
+		if( p[i] != 0 ) {
+			jobmgr_log(jm, LOG_DEBUG | LOG_CONSOLE, "Sending SIGTERM to PID %u and continuing...", p[i]);
+			jobmgr_assumes(jm, runtime_kill(p[i], SIGTERM) != -1);
+		}
+	}
+#else
 	struct timespec tts = { 2, 0 }; /* Wait 2 seconds for stray children to die after being SIGTERM'ed. */
 	struct timespec kts = { 1, 0 }; /* Wait 1 second for stray children to die after being SIGKILL'ed. */
 	uint64_t start, end, nanosec;
 	struct kevent kev;
 	int r, kq = kqueue();
-
+	
 	if (!jobmgr_assumes(jm, kq != -1)) {
 		return;
 	}
@@ -5652,6 +5668,7 @@
 			jobmgr_log(jm, LOG_NOTICE | LOG_CONSOLE, "PID %u did not die after being SIGKILL'ed 1 second ago.", p[i]);
 		}
 	}
+#endif
 }
 
 void
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/launchd-changes/attachments/20090218/d41e27a9/attachment.html>


More information about the launchd-changes mailing list