Revision
22975
Author
zarzycki@apple.com
Date
2006-12-12 08:49:59 -0800 (Tue, 12 Dec 2006)

Log Message

Switch to posix_spawn for more cases.

Modified Paths

Diff

Modified: trunk/launchd/src/launchd_core_logic.c (22974 => 22975)


--- trunk/launchd/src/launchd_core_logic.c	2006-12-07 19:43:17 UTC (rev 22974)
+++ trunk/launchd/src/launchd_core_logic.c	2006-12-12 16:49:59 UTC (rev 22975)
@@ -3383,21 +3383,15 @@
 void
 job_force_sampletool(job_t j)
 {
+	char *sample_args[] = { "sample", NULL, "1", "-mayDie", NULL };
 	char pidstr[100];
 	pid_t sp;
 	
 	snprintf(pidstr, sizeof(pidstr), "%u", j->p);
+	sample_args[1] = pidstr;
 
-	switch ((sp = fork())) {
-	case -1:
-		job_log_error(j, LOG_DEBUG, "Failed to spawn sample tool");
-		break;
-	case 0:
-		job_assumes(j, execlp("sample", "sample", pidstr, "1", "-mayDie", NULL) != -1);
-		_exit(EXIT_FAILURE);
-	default:
+	if (job_assumes(j, posix_spawnp(&sp, sample_args[0], NULL, NULL, sample_args, environ) == 0)) {
 		job_assumes(j, kevent_mod(sp, EVFILT_PROC, EV_ADD, NOTE_EXIT, 0, &kqsimple_zombie_reaper) != -1);
-		break;
 	}
 }