From source_changes at macosforge.org Mon Feb 5 13:35:42 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:39 2007 Subject: [launchd-changes] [23028] trunk/launchd/src/launchctl.c Message-ID: <20070205213542.95D7149BB46@cvs.opensource.apple.com> Revision: 23028 http://trac.macosforge.org/projects/launchd/changeset/23028 Author: zarzycki@apple.com Date: 2007-02-05 13:35:42 -0800 (Mon, 05 Feb 2007) Log Message: ----------- leopard: regression: rc.local not supported Modified Paths: -------------- trunk/launchd/src/launchctl.c Modified: trunk/launchd/src/launchctl.c =================================================================== --- trunk/launchd/src/launchctl.c 2007-01-31 23:19:40 UTC (rev 23027) +++ trunk/launchd/src/launchctl.c 2007-02-05 21:35:42 UTC (rev 23028) @@ -1279,7 +1279,7 @@ if (path_check("/etc/rc.local")) { const char *rc_local_tool[] = { _PATH_BSHELL, "/etc/rc.local", NULL }; - assumes(fwexec(rc_local_tool, false) != -1); + assumes(fwexec(rc_local_tool, true) != -1); } return 0; -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070205/4c341600/attachment.html From source_changes at macosforge.org Mon Feb 5 14:11:17 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:39 2007 Subject: [launchd-changes] [23029] trunk/launchd/src Message-ID: <20070205221117.3FCC749BC3F@cvs.opensource.apple.com> Revision: 23029 http://trac.macosforge.org/projects/launchd/changeset/23029 Author: zarzycki@apple.com Date: 2007-02-05 14:11:16 -0800 (Mon, 05 Feb 2007) Log Message: ----------- turn SystemStarter into a launchd job Modified Paths: -------------- trunk/launchd/src/Makefile.am trunk/launchd/src/Makefile.in trunk/launchd/src/SystemStarter.c trunk/launchd/src/launchctl.c Modified: trunk/launchd/src/Makefile.am =================================================================== --- trunk/launchd/src/Makefile.am 2007-02-05 21:35:42 UTC (rev 23028) +++ trunk/launchd/src/Makefile.am 2007-02-05 22:11:16 UTC (rev 23029) @@ -93,7 +93,8 @@ mkdir -p $(DESTDIR)/$(sysconfdir)/mach_init_per_user.d mkdir -p $(DESTDIR)/Library/LaunchDaemons mkdir -p $(DESTDIR)/Library/LaunchAgents + mkdir -p $(DESTDIR)/System/Library/LaunchAgents mkdir -p $(DESTDIR)/System/Library/LaunchDaemons - mkdir -p $(DESTDIR)/System/Library/LaunchAgents + cp $(srcdir)/com.apple.SystemStarter.plist $(DESTDIR)/System/Library/LaunchDaemons endif Modified: trunk/launchd/src/Makefile.in =================================================================== --- trunk/launchd/src/Makefile.in 2007-02-05 21:35:42 UTC (rev 23028) +++ trunk/launchd/src/Makefile.in 2007-02-05 22:11:16 UTC (rev 23029) @@ -1107,8 +1107,9 @@ @LIBS_ONLY_FALSE@ mkdir -p $(DESTDIR)/$(sysconfdir)/mach_init_per_user.d @LIBS_ONLY_FALSE@ mkdir -p $(DESTDIR)/Library/LaunchDaemons @LIBS_ONLY_FALSE@ mkdir -p $(DESTDIR)/Library/LaunchAgents +@LIBS_ONLY_FALSE@ mkdir -p $(DESTDIR)/System/Library/LaunchAgents @LIBS_ONLY_FALSE@ mkdir -p $(DESTDIR)/System/Library/LaunchDaemons -@LIBS_ONLY_FALSE@ mkdir -p $(DESTDIR)/System/Library/LaunchAgents +@LIBS_ONLY_FALSE@ cp $(srcdir)/com.apple.SystemStarter.plist $(DESTDIR)/System/Library/LaunchDaemons # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: Modified: trunk/launchd/src/SystemStarter.c =================================================================== --- trunk/launchd/src/SystemStarter.c 2007-02-05 21:35:42 UTC (rev 23028) +++ trunk/launchd/src/SystemStarter.c 2007-02-05 22:11:16 UTC (rev 23029) @@ -22,6 +22,9 @@ * @APPLE_APACHE_LICENSE_HEADER_END@ **/ +#include +#include +#include #include #include #include @@ -147,7 +150,27 @@ } } - exit(system_starter(anAction, aService)); + int ssec = system_starter(anAction, aService); + struct stat sb; + + if (anAction == kActionStart && stat("/etc/rc.local", &sb) != -1) { + int wstatus; + pid_t rclp; + + switch ((rclp = fork())) { + case -1: + break; + case 0: + execlp(_PATH_BSHELL, _PATH_BSHELL, "/etc/rc.local", NULL); + _exit(EXIT_FAILURE); + break; + default: + waitpid(rclp, &wstatus, 0); + break; + } + } + + exit(ssec); } Modified: trunk/launchd/src/launchctl.c =================================================================== --- trunk/launchd/src/launchctl.c 2007-02-05 21:35:42 UTC (rev 23028) +++ trunk/launchd/src/launchctl.c 2007-02-05 22:11:16 UTC (rev 23029) @@ -1274,14 +1274,6 @@ _vproc_set_global_on_demand(false); - const char *SystemStarter_tool[] = { "SystemStarter", NULL }; - assumes(fwexec(SystemStarter_tool, false) != -1); - - if (path_check("/etc/rc.local")) { - const char *rc_local_tool[] = { _PATH_BSHELL, "/etc/rc.local", NULL }; - assumes(fwexec(rc_local_tool, true) != -1); - } - return 0; } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070205/449c1acf/attachment.html From source_changes at macosforge.org Mon Feb 5 14:11:46 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:39 2007 Subject: [launchd-changes] [23030] trunk/launchd/src/com.apple.SystemStarter.plist Message-ID: <20070205221146.D34C249BC4F@cvs.opensource.apple.com> Revision: 23030 http://trac.macosforge.org/projects/launchd/changeset/23030 Author: zarzycki@apple.com Date: 2007-02-05 14:11:46 -0800 (Mon, 05 Feb 2007) Log Message: ----------- turn SystemStarter into a launchd job Added Paths: ----------- trunk/launchd/src/com.apple.SystemStarter.plist Added: trunk/launchd/src/com.apple.SystemStarter.plist =================================================================== --- trunk/launchd/src/com.apple.SystemStarter.plist (rev 0) +++ trunk/launchd/src/com.apple.SystemStarter.plist 2007-02-05 22:11:46 UTC (rev 23030) @@ -0,0 +1,12 @@ + + + + + Label + com.apple.SystemStarter + Program + /sbin/SystemStarter + RunAtLoad + + + -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070205/02d57926/attachment.html From source_changes at macosforge.org Tue Feb 6 09:50:05 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:39 2007 Subject: [launchd-changes] [23031] trunk/launchd/src/launchd_runtime.c Message-ID: <20070206175005.4A9BF49CB9A@cvs.opensource.apple.com> Revision: 23031 http://trac.macosforge.org/projects/launchd/changeset/23031 Author: zarzycki@apple.com Date: 2007-02-06 09:50:05 -0800 (Tue, 06 Feb 2007) Log Message: ----------- Code to help track down an elusive crash Modified Paths: -------------- trunk/launchd/src/launchd_runtime.c Modified: trunk/launchd/src/launchd_runtime.c =================================================================== --- trunk/launchd/src/launchd_runtime.c 2007-02-05 22:11:46 UTC (rev 23030) +++ trunk/launchd/src/launchd_runtime.c 2007-02-06 17:50:05 UTC (rev 23031) @@ -34,12 +34,14 @@ #include #include #include +#include #include #include #include #include #include #include +#include #include #include #include @@ -190,6 +192,36 @@ return NULL; } +static bool +ptr_is_in_exe(void *ptr) +{ + uint32_t i, count = _dyld_image_count(); + + for (i = 0; i < count; i++) { + const struct mach_header *header = _dyld_get_image_header(i); + uint32_t j, offset = _dyld_get_image_vmaddr_slide(i); + struct segment_command *seg; + struct load_command *cmd; + + j = 0; + cmd = (struct load_command*)((char *)header + sizeof(struct mach_header)); + + while (j < header->ncmds) { + if (cmd->cmd == LC_SEGMENT) { + seg = (struct segment_command*)cmd; + if (((uint32_t)ptr >= (seg->vmaddr + offset)) && ((uint32_t)ptr < (seg->vmaddr + offset + seg->vmsize))) { + return true; + } + } + + j++; + cmd = (struct load_command*)((char*)cmd + cmd->cmdsize); + } + } + + return false; +} + kern_return_t x_handle_kqueue(mach_port_t junk __attribute__((unused)), integer_t fd) { @@ -200,7 +232,12 @@ launchd_assumes((kevr = kevent(fd, NULL, 0, &kev, 1, &ts)) != -1); if (kevr == 1) { - (*((kq_callback *)kev.udata))(kev.udata, &kev); + if (launchd_assumes(malloc_size(kev.udata) || ptr_is_in_exe(kev.udata))) { + (*((kq_callback *)kev.udata))(kev.udata, &kev); + } else { + syslog(LOG_ERR, "kev.ident == 0x%x kev.filter == 0x%x kev.fflags = 0x%x kev.udata = 0x%x", + kev.ident, kev.filter, kev.fflags, kev.udata); + } } launchd_post_kevent(); -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070206/aeb9db8b/attachment.html From source_changes at macosforge.org Tue Feb 6 11:16:25 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:39 2007 Subject: [launchd-changes] [23032] trunk/launchd/src/launchd_runtime.c Message-ID: <20070206191625.E5C3549CCD8@cvs.opensource.apple.com> Revision: 23032 http://trac.macosforge.org/projects/launchd/changeset/23032 Author: zarzycki@apple.com Date: 2007-02-06 11:16:25 -0800 (Tue, 06 Feb 2007) Log Message: ----------- I just got off the phone with our dynamic linker engineer. This should work just as well, but with less code. Modified Paths: -------------- trunk/launchd/src/launchd_runtime.c Modified: trunk/launchd/src/launchd_runtime.c =================================================================== --- trunk/launchd/src/launchd_runtime.c 2007-02-06 17:50:05 UTC (rev 23031) +++ trunk/launchd/src/launchd_runtime.c 2007-02-06 19:16:25 UTC (rev 23032) @@ -34,7 +34,6 @@ #include #include #include -#include #include #include #include @@ -51,6 +50,7 @@ #include #include #include +#include #include "launchd_internalServer.h" #include "launchd_internal.h" @@ -192,47 +192,18 @@ return NULL; } -static bool -ptr_is_in_exe(void *ptr) -{ - uint32_t i, count = _dyld_image_count(); - - for (i = 0; i < count; i++) { - const struct mach_header *header = _dyld_get_image_header(i); - uint32_t j, offset = _dyld_get_image_vmaddr_slide(i); - struct segment_command *seg; - struct load_command *cmd; - - j = 0; - cmd = (struct load_command*)((char *)header + sizeof(struct mach_header)); - - while (j < header->ncmds) { - if (cmd->cmd == LC_SEGMENT) { - seg = (struct segment_command*)cmd; - if (((uint32_t)ptr >= (seg->vmaddr + offset)) && ((uint32_t)ptr < (seg->vmaddr + offset + seg->vmsize))) { - return true; - } - } - - j++; - cmd = (struct load_command*)((char*)cmd + cmd->cmdsize); - } - } - - return false; -} - kern_return_t x_handle_kqueue(mach_port_t junk __attribute__((unused)), integer_t fd) { struct timespec ts = { 0, 0 }; struct kevent kev; + Dl_info dli; int kevr; launchd_assumes((kevr = kevent(fd, NULL, 0, &kev, 1, &ts)) != -1); if (kevr == 1) { - if (launchd_assumes(malloc_size(kev.udata) || ptr_is_in_exe(kev.udata))) { + if (launchd_assumes(malloc_size(kev.udata) || dladdr(kev.udata, &dli))) { (*((kq_callback *)kev.udata))(kev.udata, &kev); } else { syslog(LOG_ERR, "kev.ident == 0x%x kev.filter == 0x%x kev.fflags = 0x%x kev.udata = 0x%x", -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070206/52182454/attachment.html From source_changes at macosforge.org Tue Feb 6 14:09:40 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:39 2007 Subject: [launchd-changes] [23033] trunk/launchd/src/launchd.plist.5 Message-ID: <20070206220940.AC51649D133@cvs.opensource.apple.com> Revision: 23033 http://trac.macosforge.org/projects/launchd/changeset/23033 Author: zarzycki@apple.com Date: 2007-02-06 14:09:40 -0800 (Tue, 06 Feb 2007) Log Message: ----------- Errors in "man launchd.plist" Modified Paths: -------------- trunk/launchd/src/launchd.plist.5 Modified: trunk/launchd/src/launchd.plist.5 =================================================================== --- trunk/launchd/src/launchd.plist.5 2007-02-06 19:16:25 UTC (rev 23032) +++ trunk/launchd/src/launchd.plist.5 2007-02-06 22:09:40 UTC (rev 23033) @@ -180,7 +180,7 @@ This key lets one override the default throttling policy imposed on jobs by .Nm launchd . The value is in seconds, and by default, jobs will not be spawned more than once every 10 seconds. -The principle behind this is that jobs should linger around just in case their needed again in the near future. This not only +The principle behind this is that jobs should linger around just in case they are needed again in the near future. This not only reduces the latency of responses, but it encourages developers to amortize the cost of program invocation. .It Sy InitGroups This optional key specifies whether the job should have -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070206/f78e0ddd/attachment.html From source_changes at macosforge.org Tue Feb 6 14:10:42 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:39 2007 Subject: [launchd-changes] [23034] tags/launchd-192/ Message-ID: <20070206221042.528C149D180@cvs.opensource.apple.com> Revision: 23034 http://trac.macosforge.org/projects/launchd/changeset/23034 Author: zarzycki@apple.com Date: 2007-02-06 14:10:42 -0800 (Tue, 06 Feb 2007) Log Message: ----------- "Tagging launchd-192 from https://svn.macosforge.org/repository/launchd/trunk" Added Paths: ----------- tags/launchd-192/ Copied: tags/launchd-192 (from rev 23033, trunk) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070206/1be386e3/attachment.html From source_changes at macosforge.org Wed Feb 7 08:34:09 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:39 2007 Subject: [launchd-changes] [23035] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070207163409.A35C249E0B4@cvs.opensource.apple.com> Revision: 23035 http://trac.macosforge.org/projects/launchd/changeset/23035 Author: zarzycki@apple.com Date: 2007-02-07 08:34:09 -0800 (Wed, 07 Feb 2007) Log Message: ----------- spurious logging from the libraries used by the various importers Modified Paths: -------------- trunk/launchd/src/launchd_core_logic.c Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2007-02-06 22:10:42 UTC (rev 23034) +++ trunk/launchd/src/launchd_core_logic.c 2007-02-07 16:34:09 UTC (rev 23035) @@ -1803,7 +1803,7 @@ job_assumes(j, socketpair(AF_UNIX, SOCK_STREAM, 0, execspair) != -1); - if (job_assumes(j, pipe(oepair) != -1)) { + if (!j->legacy_mach_job && job_assumes(j, pipe(oepair) != -1)) { j->log_redirect_fd = _fd(oepair[0]); job_assumes(j, fcntl(j->log_redirect_fd, F_SETFL, O_NONBLOCK) != -1); job_assumes(j, kevent_mod(j->log_redirect_fd, EVFILT_READ, EV_ADD, 0, 0, j) != -1); @@ -1822,9 +1822,11 @@ } break; case 0: - job_assumes(j, dup2(oepair[1], STDOUT_FILENO) != -1); - job_assumes(j, dup2(oepair[1], STDERR_FILENO) != -1); - job_assumes(j, close(oepair[1]) != -1); + if (!j->legacy_mach_job) { + job_assumes(j, dup2(oepair[1], STDOUT_FILENO) != -1); + job_assumes(j, dup2(oepair[1], STDERR_FILENO) != -1); + job_assumes(j, close(oepair[1]) != -1); + } job_assumes(j, close(execspair[0]) == 0); /* wait for our parent to say they've attached a kevent to us */ read(_fd(execspair[1]), &c, sizeof(c)); @@ -1845,7 +1847,9 @@ job_start_child(j); break; default: - job_assumes(j, close(oepair[1]) != -1); + if (!j->legacy_mach_job) { + job_assumes(j, close(oepair[1]) != -1); + } j->p = c; j->forkfd = _fd(execspair[0]); job_assumes(j, close(execspair[1]) == 0); -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070207/0bcd87af/attachment.html From source_changes at macosforge.org Wed Feb 7 09:39:53 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:39 2007 Subject: [launchd-changes] [23036] trunk/launchd/src/StartupItems Message-ID: <20070207173953.0491F49E19B@cvs.opensource.apple.com> Revision: 23036 http://trac.macosforge.org/projects/launchd/changeset/23036 Author: zarzycki@apple.com Date: 2007-02-07 09:39:53 -0800 (Wed, 07 Feb 2007) Log Message: ----------- Remove the IPServices StartupItem Removed Paths: ------------- trunk/launchd/src/StartupItems/IPServices trunk/launchd/src/StartupItems/IPServices.plist Deleted: trunk/launchd/src/StartupItems/IPServices =================================================================== --- trunk/launchd/src/StartupItems/IPServices 2007-02-07 16:34:09 UTC (rev 23035) +++ trunk/launchd/src/StartupItems/IPServices 2007-02-07 17:39:53 UTC (rev 23036) @@ -1,30 +0,0 @@ -#!/bin/sh - -## -# IP Services -## - -[ -f /System/Library/LaunchDaemons/com.apache.httpd.plist ] && exit 0 - -. /etc/rc.common - -StartService () -{ - if [ -a /etc/com.apple.named.conf.proxy ] - then - echo "Starting Internet address sharing" - /usr/libexec/InternetSharing - fi -} - -StopService () -{ - return 0 -} - -RestartService () -{ - return 0 -} - -RunService "$1" Deleted: trunk/launchd/src/StartupItems/IPServices.plist =================================================================== --- trunk/launchd/src/StartupItems/IPServices.plist 2007-02-07 16:34:09 UTC (rev 23035) +++ trunk/launchd/src/StartupItems/IPServices.plist 2007-02-07 17:39:53 UTC (rev 23036) @@ -1,5 +0,0 @@ -{ - Description = "Internet services"; - Provides = ("Super Server", "Config Server"); - Uses = ("mDNSResponder", "Portmap"); -} -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070207/2b38817e/attachment.html From source_changes at macosforge.org Wed Feb 7 10:26:57 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:39 2007 Subject: [launchd-changes] [23037] trunk/launchd/src Message-ID: <20070207182657.8892E49E1E3@cvs.opensource.apple.com> Revision: 23037 http://trac.macosforge.org/projects/launchd/changeset/23037 Author: zarzycki@apple.com Date: 2007-02-07 10:26:57 -0800 (Wed, 07 Feb 2007) Log Message: ----------- job_export_all() crash via launchd's Unix IPC Modified Paths: -------------- trunk/launchd/src/launchd_core_logic.c trunk/launchd/src/launchd_core_logic.h Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2007-02-07 17:39:53 UTC (rev 23036) +++ trunk/launchd/src/launchd_core_logic.c 2007-02-07 18:26:57 UTC (rev 23037) @@ -976,9 +976,7 @@ return NULL; } - job_dispatch(j, false); - - return j; + return job_dispatch(j, false); } launch_data_t @@ -1641,19 +1639,19 @@ void jobmgr_dispatch_all(jobmgr_t jm) { - jobmgr_t jmi; - job_t ji; + jobmgr_t jmi, jmn; + job_t ji, jn; - SLIST_FOREACH(jmi, &jm->submgrs, sle) { + SLIST_FOREACH_SAFE(jmi, &jm->submgrs, sle, jmn) { jobmgr_dispatch_all(jmi); } - SLIST_FOREACH(ji, &jm->jobs, sle) { + SLIST_FOREACH_SAFE(ji, &jm->jobs, sle, jn) { job_dispatch(ji, false); } } -void +job_t job_dispatch(job_t j, bool kickstart) { /* @@ -1664,15 +1662,18 @@ * * This is a classic example. The act of dispatching a job may delete it. */ - if (job_active(j)) { - return; - } else if (job_useless(j)) { - job_remove(j); - } else if (kickstart || job_keepalive(j)) { - job_start(j); - } else { - job_watch(j); + if (!job_active(j)) { + if (job_useless(j)) { + job_remove(j); + return NULL; + } else if (kickstart || job_keepalive(j)) { + job_start(j); + } else { + job_watch(j); + } } + + return j; } void @@ -3468,6 +3469,7 @@ } } + /* We don't need the _SAFE version because we return after the job_dispatch() */ SLIST_FOREACH(ji, &jm->jobs, sle) { SLIST_FOREACH(ms, &ji->machservices, sle) { if (ms->port != p) { @@ -3613,11 +3615,11 @@ void jobmgr_dispatch_all_semaphores(jobmgr_t jm) { - jobmgr_t jmi; + jobmgr_t jmi, jmn; job_t ji, jn; - SLIST_FOREACH(jmi, &jm->submgrs, sle) { + SLIST_FOREACH_SAFE(jmi, &jm->submgrs, sle, jmn) { jobmgr_dispatch_all_semaphores(jmi); } @@ -3979,10 +3981,12 @@ ms->must_match_uid = true; ms->hide = true; - job_dispatch(ji, false); + ji = job_dispatch(ji, false); } - *up_cont = machservice_port(SLIST_FIRST(&ji->machservices)); + if (job_assumes(j, ji != NULL)) { + *up_cont = machservice_port(SLIST_FIRST(&ji->machservices)); + } return 0; } @@ -4538,8 +4542,12 @@ memcpy(jr->j_binpref, bin_pref, sizeof(jr->j_binpref)); jr->j_binpref_cnt = binpref_cnt; - job_dispatch(jr, true); + jr = job_dispatch(jr, true); + if (!job_assumes(j, jr != NULL)) { + return BOOTSTRAP_NO_MEMORY; + } + if (!job_setup_machport(jr)) { job_remove(jr); return BOOTSTRAP_NO_MEMORY; Modified: trunk/launchd/src/launchd_core_logic.h =================================================================== --- trunk/launchd/src/launchd_core_logic.h 2007-02-07 17:39:53 UTC (rev 23036) +++ trunk/launchd/src/launchd_core_logic.h 2007-02-07 18:26:57 UTC (rev 23037) @@ -43,7 +43,7 @@ launch_data_t job_export_all(void); job_t job_new(jobmgr_t jm, const char *label, const char *prog, const char *const *argv, const char *stdinpath); -void job_dispatch(job_t j, bool kickstart); +job_t job_dispatch(job_t j, bool kickstart); /* returns j on success, NULL on job removal */ bool job_active(job_t j); launch_data_t job_export(job_t j); void job_stop(job_t j); -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070207/a531c817/attachment.html From source_changes at macosforge.org Wed Feb 7 12:19:37 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:39 2007 Subject: [launchd-changes] [23038] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070207201937.2E1D149E453@cvs.opensource.apple.com> Revision: 23038 http://trac.macosforge.org/projects/launchd/changeset/23038 Author: zarzycki@apple.com Date: 2007-02-07 12:19:36 -0800 (Wed, 07 Feb 2007) Log Message: ----------- posix_spawn() isn't like the rest of the Unix APIs when it comes to errno. Modified Paths: -------------- trunk/launchd/src/launchd_core_logic.c Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2007-02-07 18:26:57 UTC (rev 23037) +++ trunk/launchd/src/launchd_core_logic.c 2007-02-07 20:19:36 UTC (rev 23038) @@ -1933,10 +1933,10 @@ } if (j->prog) { - posix_spawn(&junk_pid, j->inetcompat ? file2exec : j->prog, NULL, &spattr, (char *const*)argv, environ); + errno = posix_spawn(&junk_pid, j->inetcompat ? file2exec : j->prog, NULL, &spattr, (char *const*)argv, environ); job_log_error(j, LOG_ERR, "posix_spawn(\"%s\", ...)", j->prog); } else { - posix_spawnp(&junk_pid, j->inetcompat ? file2exec : argv[0], NULL, &spattr, (char *const*)argv, environ); + errno = posix_spawnp(&junk_pid, j->inetcompat ? file2exec : argv[0], NULL, &spattr, (char *const*)argv, environ); job_log_error(j, LOG_ERR, "posix_spawnp(\"%s\", ...)", argv[0]); } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070207/0829ef5c/attachment.html From source_changes at macosforge.org Wed Feb 7 13:07:49 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:39 2007 Subject: [launchd-changes] [23039] trunk/launchd/src/launchd.c Message-ID: <20070207210749.DE2D649E4E8@cvs.opensource.apple.com> Revision: 23039 http://trac.macosforge.org/projects/launchd/changeset/23039 Author: zarzycki@apple.com Date: 2007-02-07 13:07:49 -0800 (Wed, 07 Feb 2007) Log Message: ----------- Clean up. Now if we can properly make our reflector threads go away, we should be able to go to single user mode again. :-) Modified Paths: -------------- trunk/launchd/src/launchd.c Modified: trunk/launchd/src/launchd.c =================================================================== --- trunk/launchd/src/launchd.c 2007-02-07 20:19:36 UTC (rev 23038) +++ trunk/launchd/src/launchd.c 2007-02-07 21:07:49 UTC (rev 23039) @@ -300,11 +300,11 @@ * to skip it. */ if (!h && stat(ldconf, &sb) == 0) { - job_dispatch(rlcj, true); + rlcj = job_dispatch(rlcj, true); } if (fbj) { - job_dispatch(fbj, true); + fbj = job_dispatch(fbj, true); } char *doom_why = "at instruction"; @@ -474,24 +474,15 @@ void launchd_single_user(void) { - int tries; + syslog(LOG_NOTICE, "Going to single-user mode"); + re_exec_in_single_user_mode = true; + launchd_shutdown(); - kill(-1, SIGTERM); + sleep(3); - for (tries = 0; tries < 10; tries++) { - sleep(1); - if (kill(-1, 0) == -1 && errno == ESRCH) { - goto out; - } - } - - syslog(LOG_WARNING, "Gave up waiting for processes to exit while going to single user mode, sending SIGKILL"); kill(-1, SIGKILL); - -out: - re_exec_in_single_user_mode = true; } static void signal_callback(void *obj __attribute__((unused)), struct kevent *kev) @@ -501,7 +492,7 @@ switch (kev->ident) { case SIGHUP: if (rlcj) { - job_dispatch(rlcj, true); + rlcj = job_dispatch(rlcj, true); } break; case SIGTERM: @@ -691,6 +682,7 @@ 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); } } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070207/7917bf4a/attachment.html From source_changes at macosforge.org Wed Feb 7 15:39:59 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:39 2007 Subject: [launchd-changes] [23040] trunk/launchd/src Message-ID: <20070207233959.050CC49E7EA@cvs.opensource.apple.com> Revision: 23040 http://trac.macosforge.org/projects/launchd/changeset/23040 Author: zarzycki@apple.com Date: 2007-02-07 15:39:58 -0800 (Wed, 07 Feb 2007) Log Message: ----------- Add a per job exit timeout. Modified Paths: -------------- trunk/launchd/src/launchd.plist.5 trunk/launchd/src/launchd_core_logic.c trunk/launchd/src/liblaunch_public.h Modified: trunk/launchd/src/launchd.plist.5 =================================================================== --- trunk/launchd/src/launchd.plist.5 2007-02-07 21:07:49 UTC (rev 23039) +++ trunk/launchd/src/launchd.plist.5 2007-02-07 23:39:58 UTC (rev 23040) @@ -176,6 +176,10 @@ The recommended idle time out (in seconds) to pass to the job. If no value is specified, a default time out will be supplied by .Nm launchd for use by the job at check in time. +.It Sy ExitTimeOut +The amount of time +.Nm launchd +waits before sending a SIGKILL signal. The default value is 20 seconds. The value zero is interpreted as infinity. .It Sy ThrottleInterval This key lets one override the default throttling policy imposed on jobs by .Nm launchd . Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2007-02-07 21:07:49 UTC (rev 23039) +++ trunk/launchd/src/launchd_core_logic.c 2007-02-07 23:39:58 UTC (rev 23040) @@ -87,6 +87,7 @@ #define LAUNCHD_MIN_JOB_RUN_TIME 10 #define LAUNCHD_ADVISABLE_IDLE_TIMEOUT 30 +#define LAUNCHD_DEFAULT_EXIT_TIMEOUT 20 extern char **environ; @@ -254,8 +255,10 @@ int forkfd; int log_redirect_fd; int nice; - int timeout; + unsigned int timeout; + unsigned int exit_timeout; int stdout_err_fd; + struct timeval sent_sigterm_time; time_t start_time; time_t min_run_time; unsigned int start_interval; @@ -405,6 +408,11 @@ { if (j->p) { job_assumes(j, kill(j->p, SIGTERM) != -1); + job_assumes(j, gettimeofday(&j->sent_sigterm_time, NULL) != -1); + if (j->exit_timeout) { + job_assumes(j, kevent_mod((uintptr_t)&j->exit_timeout, EVFILT_TIMER, + EV_ADD|EV_ONESHOT, NOTE_SECONDS, j->exit_timeout, j) != -1); + } } } @@ -516,9 +524,6 @@ if (!job_active(ji)) { job_remove(ji); } else { - if (debug_shutdown_hangs) { - job_assumes(ji, kevent_mod((uintptr_t)ji, EVFILT_TIMER, EV_ADD|EV_ONESHOT, NOTE_SECONDS, 8, ji) != -1); - } job_stop(ji); } } @@ -662,6 +667,9 @@ if (j->start_interval) { job_assumes(j, kevent_mod((uintptr_t)&j->start_interval, EVFILT_TIMER, EV_DELETE, 0, 0, NULL) != -1); } + if (j->exit_timeout) { + kevent_mod((uintptr_t)&j->exit_timeout, EVFILT_TIMER, EV_DELETE, 0, 0, NULL); + } kevent_mod((uintptr_t)j, EVFILT_TIMER, EV_DELETE, 0, 0, NULL); free(j); @@ -907,6 +915,7 @@ j->mgr = jm; j->min_run_time = LAUNCHD_MIN_JOB_RUN_TIME; j->timeout = LAUNCHD_ADVISABLE_IDLE_TIMEOUT; + j->exit_timeout = LAUNCHD_DEFAULT_EXIT_TIMEOUT; j->currently_ignored = true; j->ondemand = true; j->checkedin = true; @@ -1162,6 +1171,16 @@ job_import_integer(job_t j, const char *key, long long value) { switch (key[0]) { + case 'e': + case 'E': + if (strcasecmp(key, LAUNCH_JOBKEY_EXITTIMEOUT) == 0) { + if (value < 0) { + job_log(j, LOG_WARNING, "Exit timeout less zero. Ignoring."); + } else { + j->exit_timeout = value; + } + } + break; case 'n': case 'N': if (strcasecmp(key, LAUNCH_JOBKEY_NICE) == 0) { @@ -1577,6 +1596,7 @@ void job_reap(job_t j) { + struct timeval tve, tvd; struct rusage ru; int status; @@ -1596,12 +1616,24 @@ return; } + job_assumes(j, gettimeofday(&tve, NULL) != -1); + if (j->wait_reply_port) { job_log(j, LOG_DEBUG, "MPM wait reply being sent"); job_assumes(j, job_mig_wait_reply(j->wait_reply_port, 0, status) == 0); j->wait_reply_port = MACH_PORT_NULL; } + if (j->sent_sigterm_time.tv_sec) { + double delta; + + timersub(&tve, &j->sent_sigterm_time, &tvd); + + delta = (double)tvd.tv_sec + (double)tvd.tv_usec / (double)1000000; + + job_log(j, tvd.tv_sec ? LOG_NOTICE : LOG_INFO, "Exited %f seconds after SIGTERM was sent", delta); + } + timeradd(&ru.ru_utime, &j->ru.ru_utime, &j->ru.ru_utime); timeradd(&ru.ru_stime, &j->ru.ru_stime, &j->ru.ru_stime); j->ru.ru_maxrss += ru.ru_maxrss; @@ -1724,14 +1756,14 @@ } break; case EVFILT_TIMER: - if ((uintptr_t)j == kev->ident) { - if (j->p && job_assumes(j, debug_shutdown_hangs)) { + if ((uintptr_t)j == kev->ident || (uintptr_t)&j->start_interval == kev->ident) { + job_dispatch(j, true); + } else if ((uintptr_t)&j->exit_timeout == kev->ident) { + if (debug_shutdown_hangs) { job_force_sampletool(j); - } else { - job_dispatch(j, true); } - } else if ((uintptr_t)&j->start_interval == kev->ident) { - job_dispatch(j, true); + job_log(j, LOG_WARNING, "Exit timeout elapsed (%u seconds). Killing.", j->exit_timeout); + job_assumes(j, kill(j->p, SIGKILL) != -1); } else { calendarinterval_callback(j, kev); } @@ -1788,6 +1820,9 @@ job_log(j, LOG_DEBUG, "Starting"); + j->sent_sigterm_time.tv_sec = 0; + j->sent_sigterm_time.tv_usec = 0; + /* FIXME, using stdinpath is a hack for re-reading the conf file */ if (j->stdinpath) { sipc = true; Modified: trunk/launchd/src/liblaunch_public.h =================================================================== --- trunk/launchd/src/liblaunch_public.h 2007-02-07 21:07:49 UTC (rev 23039) +++ trunk/launchd/src/liblaunch_public.h 2007-02-07 23:39:58 UTC (rev 23040) @@ -58,6 +58,7 @@ #define LAUNCH_JOBKEY_USERNAME "UserName" #define LAUNCH_JOBKEY_GROUPNAME "GroupName" #define LAUNCH_JOBKEY_TIMEOUT "TimeOut" +#define LAUNCH_JOBKEY_EXITTIMEOUT "ExitTimeOut" #define LAUNCH_JOBKEY_INITGROUPS "InitGroups" #define LAUNCH_JOBKEY_SOCKETS "Sockets" #define LAUNCH_JOBKEY_MACHSERVICES "MachServices" -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070207/270c1b4a/attachment.html From source_changes at macosforge.org Wed Feb 7 17:28:03 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:39 2007 Subject: [launchd-changes] [23041] trunk/launchd/src/launchd.c Message-ID: <20070208012803.9428049EA19@cvs.opensource.apple.com> Revision: 23041 http://trac.macosforge.org/projects/launchd/changeset/23041 Author: zarzycki@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 #include #include +#include #include #include #include @@ -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 From source_changes at macosforge.org Thu Feb 8 07:21:27 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:39 2007 Subject: [launchd-changes] [23042] trunk/launchd/src Message-ID: <20070208152127.67EE949F223@cvs.opensource.apple.com> Revision: 23042 http://trac.macosforge.org/projects/launchd/changeset/23042 Author: zarzycki@apple.com Date: 2007-02-08 07:21:26 -0800 (Thu, 08 Feb 2007) Log Message: ----------- Add plist option to mimic the kernel's KERN_PROCDELAYTERM Modified Paths: -------------- trunk/launchd/src/launchd.c trunk/launchd/src/launchd.h trunk/launchd/src/launchd.plist.5 trunk/launchd/src/launchd_core_logic.c trunk/launchd/src/launchd_core_logic.h trunk/launchd/src/liblaunch_public.h Modified: trunk/launchd/src/launchd.c =================================================================== --- trunk/launchd/src/launchd.c 2007-02-08 01:28:03 UTC (rev 23041) +++ trunk/launchd/src/launchd.c 2007-02-08 15:21:26 UTC (rev 23042) @@ -110,7 +110,7 @@ static const char *launchctl_bootstrap_tool[] = { "/bin/launchctl", /* "bootstrap", */ NULL }; sigset_t blocked_signals = 0; -bool shutdown_in_progress = false; +static bool shutdown_in_progress = false; bool debug_shutdown_hangs = false; bool network_up = false; int batch_disabler_count = 0; @@ -469,7 +469,7 @@ rlcj = NULL; - jobmgr_remove_all_inactive(root_jobmgr); + root_jobmgr = jobmgr_shutdown(root_jobmgr); } void @@ -676,7 +676,7 @@ void launchd_post_kevent(void) { - if (shutdown_in_progress && jobmgr_is_idle(root_jobmgr)) { + if (shutdown_in_progress && (!root_jobmgr || jobmgr_is_idle(root_jobmgr))) { shutdown_in_progress = false; if (getpid() == 1) { Modified: trunk/launchd/src/launchd.h =================================================================== --- trunk/launchd/src/launchd.h 2007-02-08 01:28:03 UTC (rev 23041) +++ trunk/launchd/src/launchd.h 2007-02-08 15:21:26 UTC (rev 23042) @@ -34,7 +34,6 @@ extern kq_callback kqsimple_zombie_reaper; extern sigset_t blocked_signals; -extern bool shutdown_in_progress; extern bool debug_shutdown_hangs; extern bool network_up; extern int batch_disabler_count; Modified: trunk/launchd/src/launchd.plist.5 =================================================================== --- trunk/launchd/src/launchd.plist.5 2007-02-08 01:28:03 UTC (rev 23041) +++ trunk/launchd/src/launchd.plist.5 2007-02-08 15:21:26 UTC (rev 23042) @@ -271,6 +271,12 @@ This optional key specifies what .Xr nice 3 value should be applied to the daemon. +.It Sy HopefullyExitsLast +This optional key causes programs to exit in a second wave during system +shutdown. This key exists because some jobs don't reference count their +clients, and therefore do not know when it is safe to exit. The use of this key +should be considered a temporary solution until the software can be changed to +properly reference count clients. .It Sy LowPriorityIO This optional key specifies whether the kernel should consider this daemon to be low priority when doing file system I/O. .It Sy LaunchOnlyOnce Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2007-02-08 01:28:03 UTC (rev 23041) +++ trunk/launchd/src/launchd_core_logic.c 2007-02-08 15:21:26 UTC (rev 23042) @@ -199,7 +199,7 @@ char *jm_stdout; char *jm_stderr; unsigned int global_on_demand_cnt; - unsigned int transfer_bstrap:1; + unsigned int transfer_bstrap:1, sent_stop_to_hopeful_jobs:1, shutting_down:1; char name[0]; }; @@ -208,6 +208,7 @@ static jobmgr_t jobmgr_new(jobmgr_t jm, mach_port_t requestorport, mach_port_t checkin_port); static jobmgr_t jobmgr_parent(jobmgr_t jm); +static jobmgr_t jobmgr_tickle(jobmgr_t jm); static void jobmgr_dispatch_all(jobmgr_t jm); static job_t jobmgr_new_anonymous(jobmgr_t jm); static job_t job_mig_intran2(jobmgr_t jm, mach_port_t p); @@ -268,7 +269,7 @@ anonymous:1; mode_t mask; unsigned int globargv:1, wait4debugger:1, unload_at_exit:1, stall_before_exec:1, only_once:1, - currently_ignored:1, forced_peers_to_demand_mode:1, setnice:1; + currently_ignored:1, forced_peers_to_demand_mode:1, setnice:1, hopefully_exits_last:1; char label[0]; }; @@ -510,23 +511,27 @@ return r; } -void -jobmgr_remove_all_inactive(jobmgr_t jm) +jobmgr_t +jobmgr_shutdown(jobmgr_t jm) { jobmgr_t jmi, jmn; job_t ji, jn; SLIST_FOREACH_SAFE(jmi, &jm->submgrs, sle, jmn) { - jobmgr_remove_all_inactive(jmi); + jobmgr_shutdown(jmi); } SLIST_FOREACH_SAFE(ji, &jm->jobs, sle, jn) { if (!job_active(ji)) { job_remove(ji); - } else { + } else if (!ji->hopefully_exits_last) { job_stop(ji); } } + + jm->shutting_down = true; + + return jobmgr_tickle(jm); } void @@ -595,10 +600,6 @@ } } - if (job_assumes(j, j->mgr)) { - SLIST_REMOVE(&j->mgr->jobs, j, job_s, sle); - } - if (j->forkfd) { job_assumes(j, close(j->forkfd) != -1); } @@ -672,6 +673,12 @@ } kevent_mod((uintptr_t)j, EVFILT_TIMER, EV_DELETE, 0, 0, NULL); + + if (job_assumes(j, j->mgr)) { + SLIST_REMOVE(&j->mgr->jobs, j, job_s, sle); + jobmgr_tickle(j->mgr); + } + free(j); } @@ -894,7 +901,7 @@ int i, cc = 0; job_t j; - if (shutdown_in_progress) { + if (jm->shutting_down) { errno = EINVAL; return NULL; } @@ -1036,6 +1043,12 @@ j->debug = value; } break; + case 'h': + case 'H': + if (strcasecmp(key, LAUNCH_JOBKEY_HOPEFULLYEXITSLAST) == 0) { + j->hopefully_exits_last = value; + } + break; case 's': case 'S': if (strcasecmp(key, LAUNCH_JOBKEY_SESSIONCREATE) == 0) { @@ -2805,7 +2818,7 @@ } job_log(j, LOG_INFO, "Exited. Was only configured to run once."); return true; - } else if (shutdown_in_progress) { + } else if (j->mgr->shutting_down) { job_log(j, LOG_INFO, "Exited while shutdown in progress."); return true; } else if (!j->checkedin && (!SLIST_EMPTY(&j->sockets) || !SLIST_EMPTY(&j->machservices))) { @@ -3162,6 +3175,35 @@ } } +jobmgr_t +jobmgr_tickle(jobmgr_t jm) +{ + job_t ji; + + if (jm->sent_stop_to_hopeful_jobs || !jm->shutting_down) { + return jm; + } + + SLIST_FOREACH(ji, &jm->jobs, sle) { + if (ji->p && !ji->hopefully_exits_last) { + return jm; + } + } + + SLIST_FOREACH(ji, &jm->jobs, sle) { + job_stop(ji); + } + + jm->sent_stop_to_hopeful_jobs = true; + + if (jobmgr_is_idle(jm)) { + jobmgr_remove(jm); + return NULL; + } + + return jm; +} + bool jobmgr_is_idle(jobmgr_t jm) { @@ -3321,11 +3363,7 @@ */ if (jm->req_port == port) { - if (jm == root_jobmgr) { - launchd_shutdown(); - } else { - return jobmgr_remove(jm); - } + jobmgr_shutdown(jm); } SLIST_FOREACH_SAFE(jmi, &jm->submgrs, sle, jmn) { Modified: trunk/launchd/src/launchd_core_logic.h =================================================================== --- trunk/launchd/src/launchd_core_logic.h 2007-02-08 01:28:03 UTC (rev 23041) +++ trunk/launchd/src/launchd_core_logic.h 2007-02-08 15:21:26 UTC (rev 23042) @@ -32,7 +32,7 @@ void jobmgr_set_stdout(jobmgr_t jm, const char *what); void jobmgr_set_stderr(jobmgr_t jm, const char *what); bool jobmgr_is_idle(jobmgr_t jm); -void jobmgr_remove_all_inactive(jobmgr_t jm); +jobmgr_t jobmgr_shutdown(jobmgr_t jm); void jobmgr_dispatch_all_semaphores(jobmgr_t jm); job_t jobmgr_find(jobmgr_t jm, const char *label); void jobmgr_delete_anything_with_port(jobmgr_t jm, mach_port_t port); Modified: trunk/launchd/src/liblaunch_public.h =================================================================== --- trunk/launchd/src/liblaunch_public.h 2007-02-08 01:28:03 UTC (rev 23041) +++ trunk/launchd/src/liblaunch_public.h 2007-02-08 15:21:26 UTC (rev 23042) @@ -78,6 +78,7 @@ #define LAUNCH_JOBKEY_USERENVIRONMENTVARIABLES "UserEnvironmentVariables" #define LAUNCH_JOBKEY_UMASK "Umask" #define LAUNCH_JOBKEY_NICE "Nice" +#define LAUNCH_JOBKEY_HOPEFULLYEXITSLAST "HopefullyExitsLast" #define LAUNCH_JOBKEY_LOWPRIORITYIO "LowPriorityIO" #define LAUNCH_JOBKEY_SESSIONCREATE "SessionCreate" #define LAUNCH_JOBKEY_SOFTRESOURCELIMITS "SoftResourceLimits" -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070208/e8ef388f/attachment.html From source_changes at macosforge.org Thu Feb 8 07:34:55 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:39 2007 Subject: [launchd-changes] [23043] trunk/launchd/src/shutdown_debugger.c Message-ID: <20070208153455.2EA3049F235@cvs.opensource.apple.com> Revision: 23043 http://trac.macosforge.org/projects/launchd/changeset/23043 Author: zarzycki@apple.com Date: 2007-02-08 07:34:54 -0800 (Thu, 08 Feb 2007) Log Message: ----------- Shutdown sampling is holding up system shutdown Modified Paths: -------------- trunk/launchd/src/shutdown_debugger.c Modified: trunk/launchd/src/shutdown_debugger.c =================================================================== --- trunk/launchd/src/shutdown_debugger.c 2007-02-08 15:21:26 UTC (rev 23042) +++ trunk/launchd/src/shutdown_debugger.c 2007-02-08 15:34:54 UTC (rev 23043) @@ -33,6 +33,7 @@ static void populate_proc_list(void); static void debug_machports(pid_t pid, const char *pname); static void debug_machports2(pid_t pid, FILE *where); +static void do_stackshot(void); static int kq; @@ -70,6 +71,8 @@ closedir(thedir); + do_stackshot(); + assert((kq = kqueue()) != -1); debug_machports(1, "launchd"); @@ -524,3 +527,11 @@ fprintf(where, "Finished.\n"); return; } + +void +do_stackshot(void) +{ + /* yes, we really mean to exec without fork at this point in time */ + execl("/usr/libexec/stackshot", "/usr/libexec/stackshot", "-i", "-f", "./shutdown-stackshot.log", NULL); + _exit(EXIT_FAILURE); +} -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070208/e0ed04df/attachment.html From source_changes at macosforge.org Thu Feb 8 09:26:17 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:39 2007 Subject: [launchd-changes] [23044] trunk/launchd/src/StartupItems Message-ID: <20070208172617.AF54049F2B6@cvs.opensource.apple.com> Revision: 23044 http://trac.macosforge.org/projects/launchd/changeset/23044 Author: zarzycki@apple.com Date: 2007-02-08 09:26:17 -0800 (Thu, 08 Feb 2007) Log Message: ----------- Christopher Ryan says that I can remove this right away. Removed Paths: ------------- trunk/launchd/src/StartupItems/AppleShare trunk/launchd/src/StartupItems/AppleShare.plist Deleted: trunk/launchd/src/StartupItems/AppleShare =================================================================== --- trunk/launchd/src/StartupItems/AppleShare 2007-02-08 15:34:54 UTC (rev 23043) +++ trunk/launchd/src/StartupItems/AppleShare 2007-02-08 17:26:17 UTC (rev 23044) @@ -1,29 +0,0 @@ -#!/bin/sh - -## -# Apple File Protocol -## - -[ -f /System/Library/LaunchDaemons/com.apple.AppleFileServer.plist ] && exit 0 - -. /etc/rc.common - -StartService () -{ - if [ "${AFPSERVER:=-NO-}" = "-YES-" ]; then - echo "Starting Apple File Service" - /usr/sbin/AppleFileServer - fi -} - -StopService () -{ - return 0 -} - -RestartService () -{ - return 0 -} - -RunService "$1" Deleted: trunk/launchd/src/StartupItems/AppleShare.plist =================================================================== --- trunk/launchd/src/StartupItems/AppleShare.plist 2007-02-08 15:34:54 UTC (rev 23043) +++ trunk/launchd/src/StartupItems/AppleShare.plist 2007-02-08 17:26:17 UTC (rev 23044) @@ -1,5 +0,0 @@ -{ - Description = "Apple File Service"; - Provides = ("Apple File Service"); - Requires = ("Disks"); -} -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070208/76c1b97d/attachment.html From source_changes at macosforge.org Thu Feb 8 10:04:07 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:39 2007 Subject: [launchd-changes] [23045] trunk/launchd/src Message-ID: <20070208180407.8B82049F2F5@cvs.opensource.apple.com> Revision: 23045 http://trac.macosforge.org/projects/launchd/changeset/23045 Author: zarzycki@apple.com Date: 2007-02-08 10:04:06 -0800 (Thu, 08 Feb 2007) Log Message: ----------- Dead code deletion. Modified Paths: -------------- trunk/launchd/src/launchd.8 trunk/launchd/src/launchd.c trunk/launchd/src/launchd.h trunk/launchd/src/launchd_core_logic.c Modified: trunk/launchd/src/launchd.8 =================================================================== --- trunk/launchd/src/launchd.8 2007-02-08 17:26:17 UTC (rev 23044) +++ trunk/launchd/src/launchd.8 2007-02-08 18:04:06 UTC (rev 23045) @@ -37,14 +37,10 @@ is invoked by the kernel to run as the first process on the system and to further bootstrap the rest of the system. .Sh OPTIONS .Bl -tag -width -indent -.It Fl d -Daemonize. Useful when passing a command to launchd on the command line. .It Fl D Debug. Prints syslog messages to stderr and adjusts logging via .Xr syslog 3 to LOG_DEBUG. -.It Fl S Ar SessionType -Instruct launchd to which session type it is. .El .Sh OPTIONS WHEN RUN AS PID 1 .Bl -tag -width -indent Modified: trunk/launchd/src/launchd.c =================================================================== --- trunk/launchd/src/launchd.c 2007-02-08 17:26:17 UTC (rev 23044) +++ trunk/launchd/src/launchd.c 2007-02-08 18:04:06 UTC (rev 23045) @@ -83,12 +83,10 @@ extern char **environ; static void signal_callback(void *, struct kevent *); -static void ppidexit_callback(void); static void debugshutdown_callback(void); static void pfsystem_callback(void *, struct kevent *); static kq_callback kqsignal_callback = signal_callback; -static kq_callback kqppidexit_callback = (kq_callback)ppidexit_callback; static kq_callback kqdebugshutdown_callback = (kq_callback)debugshutdown_callback; static kq_callback kqpfsystem_callback = pfsystem_callback; @@ -123,17 +121,15 @@ SIGTTIN, SIGTTOU, SIGIO, SIGXCPU, SIGXFSZ, SIGVTALRM, SIGPROF, SIGWINCH, SIGINFO, SIGUSR1, SIGUSR2 }; - bool sflag = false, dflag = false, Dflag = false; + bool sflag = false, Dflag = false; char ldconf[PATH_MAX] = PID1LAUNCHD_CONF; const char *h = getenv("HOME"); - const char *session_type = NULL; const char *optargs = NULL; - job_t fbj = NULL; struct stat sb; size_t i, checkin_fdcnt = 0; int *checkin_fds = NULL; mach_port_t checkin_mport = MACH_PORT_NULL; - int ch, ker, logopts; + int ch, logopts; testfd_or_openfd(STDIN_FILENO, _PATH_DEVNULL, O_RDONLY); testfd_or_openfd(STDOUT_FILENO, _PATH_DEVNULL, O_WRONLY); @@ -200,14 +196,12 @@ if (getpid() == 1) { optargs = "s"; } else { - optargs = "DS:dh"; + optargs = "Dh"; } while ((ch = getopt(argc, argv, optargs)) != -1) { switch (ch) { - case 'S': session_type = optarg; break; /* what type of session we're creating */ case 'D': Dflag = true; break; /* debug */ - case 'd': dflag = true; break; /* daemonize */ case 's': sflag = true; break; /* single user */ case 'h': usage(stdout); break; /* help */ case '?': /* we should do something with the global optopt variable here */ @@ -222,10 +216,6 @@ /* main phase three: get the party started */ - if (dflag) { - launchd_assumes(daemon(0, 0) == 0); - } - logopts = LOG_PID|LOG_CONS; if (Dflag) { logopts |= LOG_PERROR; @@ -254,10 +244,6 @@ rlcj = job_new(root_jobmgr, READCONF_LABEL, NULL, launchctl_bootstrap_tool, ldconf); launchd_assert(rlcj != NULL); - if (argv[0]) { - fbj = job_new(root_jobmgr, FIRSTBORN_LABEL, NULL, (const char *const *)argv, NULL); - } - if (NULL == getenv("PATH")) { setenv("PATH", _PATH_STDPATH, 1); } @@ -270,27 +256,6 @@ monitor_networking_state(); - if (session_type) { - pid_t pp = getppid(); - - /* As a per session launchd, we need to exit if our parent dies. - * - * Normally, in Unix, SIGHUP would cause us to exit, but we're a - * daemon, and daemons use SIGHUP to signal the need to reread - * configuration files. "Weee." - */ - - if (pp == 1) { - exit(EXIT_SUCCESS); - } - - ker = kevent_mod(pp, EVFILT_PROC, EV_ADD, NOTE_EXIT, 0, &kqppidexit_callback); - - if (ker == -1) { - exit(launchd_assumes(errno == ESRCH) ? EXIT_SUCCESS : EXIT_FAILURE); - } - } - /* * We cannot stat() anything in the home directory right now. * @@ -304,10 +269,6 @@ rlcj = job_dispatch(rlcj, true); } - if (fbj) { - fbj = job_dispatch(fbj, true); - } - char *doom_why = "at instruction"; switch (setjmp(doom_doom_doom)) { case 0: @@ -431,17 +392,6 @@ } void -ppidexit_callback(void) -{ - syslog(LOG_INFO, "Parent process exited"); - - launchd_shutdown(); - - /* Let's just bail for now. We should really try to wait for jobs to exit first. */ - exit(EXIT_SUCCESS); -} - -void launchd_shutdown(void) { if (shutdown_in_progress) { Modified: trunk/launchd/src/launchd.h =================================================================== --- trunk/launchd/src/launchd.h 2007-02-08 17:26:17 UTC (rev 23044) +++ trunk/launchd/src/launchd.h 2007-02-08 18:04:06 UTC (rev 23045) @@ -26,7 +26,6 @@ #include "libbootstrap_public.h" #include "launchd_runtime.h" -#define FIRSTBORN_LABEL "com.apple.launchd.firstborn" #define READCONF_LABEL "com.apple.launchd.readconfig" struct kevent; Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2007-02-08 17:26:17 UTC (rev 23044) +++ trunk/launchd/src/launchd_core_logic.c 2007-02-08 18:04:06 UTC (rev 23045) @@ -263,10 +263,9 @@ time_t start_time; time_t min_run_time; unsigned int start_interval; - unsigned int checkedin:1, firstborn:1, debug:1, inetcompat:1, inetcompat_wait:1, + unsigned int checkedin:1, anonymous:1, debug:1, inetcompat:1, inetcompat_wait:1, ondemand:1, session_create:1, low_pri_io:1, no_init_groups:1, priv_port_has_senders:1, - importing_global_env:1, importing_hard_limits:1, setmask:1, legacy_mach_job:1, runatload:1, - anonymous:1; + importing_global_env:1, importing_hard_limits:1, setmask:1, legacy_mach_job:1, runatload:1; mode_t mask; unsigned int globargv:1, wait4debugger:1, unload_at_exit:1, stall_before_exec:1, only_once:1, currently_ignored:1, forced_peers_to_demand_mode:1, setnice:1, hopefully_exits_last:1; @@ -926,7 +925,6 @@ j->currently_ignored = true; j->ondemand = true; j->checkedin = true; - j->firstborn = (strcmp(label, FIRSTBORN_LABEL) == 0); if (prog) { j->prog = strdup(prog); @@ -1760,13 +1758,7 @@ switch (kev->filter) { case EVFILT_PROC: job_reap(j); - - if (j->firstborn) { - job_log(j, LOG_DEBUG, "first born died, begin shutdown"); - launchd_shutdown(); - } else { - job_dispatch(j, false); - } + job_dispatch(j, false); break; case EVFILT_TIMER: if ((uintptr_t)j == kev->ident || (uintptr_t)&j->start_interval == kev->ident) { @@ -1879,14 +1871,6 @@ job_assumes(j, close(execspair[0]) == 0); /* wait for our parent to say they've attached a kevent to us */ read(_fd(execspair[1]), &c, sizeof(c)); - if (j->firstborn) { - setpgid(getpid(), getpid()); - if (isatty(STDIN_FILENO)) { - if (tcsetpgrp(STDIN_FILENO, getpid()) == -1) { - job_log_error(j, LOG_WARNING, "tcsetpgrp()"); - } - } - } if (sipc) { job_assumes(j, close(spair[0]) == 0); -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070208/780106ff/attachment.html From source_changes at macosforge.org Thu Feb 8 14:39:50 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:39 2007 Subject: [launchd-changes] [23046] trunk/launchd/src Message-ID: <20070208223950.B40FC49F7C0@cvs.opensource.apple.com> Revision: 23046 http://trac.macosforge.org/projects/launchd/changeset/23046 Author: zarzycki@apple.com Date: 2007-02-08 14:39:50 -0800 (Thu, 08 Feb 2007) Log Message: ----------- More shutdown logic clean up and sanity checking. Modified Paths: -------------- trunk/launchd/src/launchd_core_logic.c trunk/launchd/src/launchd_runtime.c Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2007-02-08 18:04:06 UTC (rev 23045) +++ trunk/launchd/src/launchd_core_logic.c 2007-02-08 22:39:50 UTC (rev 23046) @@ -516,6 +516,8 @@ jobmgr_t jmi, jmn; job_t ji, jn; + jobmgr_log(jm, LOG_DEBUG, "Beginning job manager shutdown"); + SLIST_FOREACH_SAFE(jmi, &jm->submgrs, sle, jmn) { jobmgr_shutdown(jmi); } @@ -539,18 +541,22 @@ jobmgr_t jmi; job_t ji; - while ((jmi = SLIST_FIRST(&jm->submgrs))) { - jobmgr_remove(jmi); + jobmgr_log(jm, LOG_DEBUG, "Removed job manager"); + + if (!jobmgr_assumes(jm, SLIST_EMPTY(&jm->submgrs))) { + while ((jmi = SLIST_FIRST(&jm->submgrs))) { + jobmgr_remove(jmi); + } } + /* We should have one job left and it should be the anonymous job */ + ji = SLIST_FIRST(&jm->jobs); + jobmgr_assumes(jm, ji && ji == jm->anonj && (SLIST_NEXT(ji, sle) == NULL)); + while ((ji = SLIST_FIRST(&jm->jobs))) { job_remove(ji); } - if (jm->parentmgr) { - SLIST_REMOVE(&jm->parentmgr->submgrs, jm, jobmgr_s, sle); - } - if (jm->req_port) { jobmgr_assumes(jm, launchd_mport_deallocate(jm->req_port) == KERN_SUCCESS); } @@ -570,6 +576,11 @@ if (jm->jm_stderr) { free(jm->jm_stderr); } + + if (jm->parentmgr) { + SLIST_REMOVE(&jm->parentmgr->submgrs, jm, jobmgr_s, sle); + jobmgr_tickle(jm->parentmgr); + } free(jm); } @@ -590,20 +601,16 @@ job_set_global_on_demand(j, false); } - if (j->p && !j->anonymous) { - if (kevent_mod(j->p, EVFILT_PROC, EV_ADD, NOTE_EXIT, 0, &kqsimple_zombie_reaper) == -1) { - job_reap(j); - } else { - /* we've attached the simple zombie reaper, we're going to delete the job before it is dead */ - job_stop(j); - } + if (!job_assumes(j, j->p == 0)) { + job_assumes(j, kill(j->p, SIGKILL) != -1); + job_reap(j); } - if (j->forkfd) { + if (!job_assumes(j, j->forkfd == 0)) { job_assumes(j, close(j->forkfd) != -1); } - if (j->log_redirect_fd) { + if (!job_assumes(j, j->log_redirect_fd == 0)) { job_assumes(j, close(j->log_redirect_fd) != -1); } @@ -2803,7 +2810,16 @@ job_log(j, LOG_INFO, "Exited. Was only configured to run once."); return true; } else if (j->mgr->shutting_down) { - job_log(j, LOG_INFO, "Exited while shutdown in progress."); + unsigned int cnt = 0; + job_t ji; + + SLIST_FOREACH(ji, &j->mgr->jobs, sle) { + if (ji->p) { + cnt++; + } + } + + job_log(j, LOG_INFO, "Exited while shutdown in progress. Processes remaining: %u", cnt); return true; } else if (!j->checkedin && (!SLIST_EMPTY(&j->sockets) || !SLIST_EMPTY(&j->machservices))) { job_log(j, LOG_WARNING, "Failed to check-in!"); @@ -3193,6 +3209,10 @@ { job_t ji; + if (!SLIST_EMPTY(&jm->submgrs)) { + return false; + } + SLIST_FOREACH(ji, &jm->jobs, sle) { if (ji->p) { return false; @@ -3320,6 +3340,8 @@ jobmgr_assumes(jmr, jmr->anonj != NULL); + jobmgr_log(jmr, LOG_DEBUG, "Created job manager"); + return jmr; out_bad: Modified: trunk/launchd/src/launchd_runtime.c =================================================================== --- trunk/launchd/src/launchd_runtime.c 2007-02-08 18:04:06 UTC (rev 23045) +++ trunk/launchd/src/launchd_runtime.c 2007-02-08 22:39:50 UTC (rev 23046) @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -578,7 +579,7 @@ /* XXX - So very gross */ if (gc_this_jobmgr) { - jobmgr_remove(gc_this_jobmgr); + jobmgr_shutdown(gc_this_jobmgr); gc_this_jobmgr = NULL; } @@ -674,7 +675,9 @@ pthread_mutex_lock(&ourlock); if (ourlogfile == NULL) { + rename("/var/log/launchd_raw.log", "/var/log/launchd_raw-old.log"); ourlogfile = fopen("/var/log/launchd_raw.log", "a"); + chmod("/var/log/launchd_raw.log", DEFFILEMODE); } pthread_mutex_unlock(&ourlock); -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070208/d62095a8/attachment.html From source_changes at macosforge.org Thu Feb 8 14:43:27 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:40 2007 Subject: [launchd-changes] [23047] tags/launchd-193/ Message-ID: <20070208224327.DB01049F7C6@cvs.opensource.apple.com> Revision: 23047 http://trac.macosforge.org/projects/launchd/changeset/23047 Author: zarzycki@apple.com Date: 2007-02-08 14:43:27 -0800 (Thu, 08 Feb 2007) Log Message: ----------- "Tagging launchd-193 from https://svn.macosforge.org/repository/launchd/trunk" Added Paths: ----------- tags/launchd-193/ Copied: tags/launchd-193 (from rev 23046, trunk) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070208/3e686ac6/attachment.html From source_changes at macosforge.org Thu Feb 8 14:48:29 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:40 2007 Subject: [launchd-changes] [23048] trunk/launchd/src Message-ID: <20070208224829.6077349F7E0@cvs.opensource.apple.com> Revision: 23048 http://trac.macosforge.org/projects/launchd/changeset/23048 Author: zarzycki@apple.com Date: 2007-02-08 14:48:29 -0800 (Thu, 08 Feb 2007) Log Message: ----------- Symbol clean up. Modified Paths: -------------- trunk/launchd/src/launchd_core_logic.c trunk/launchd/src/launchd_core_logic.h Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2007-02-08 22:43:27 UTC (rev 23047) +++ trunk/launchd/src/launchd_core_logic.c 2007-02-08 22:48:29 UTC (rev 23048) @@ -209,6 +209,7 @@ static jobmgr_t jobmgr_new(jobmgr_t jm, mach_port_t requestorport, mach_port_t checkin_port); static jobmgr_t jobmgr_parent(jobmgr_t jm); static jobmgr_t jobmgr_tickle(jobmgr_t jm); +static void jobmgr_remove(jobmgr_t jm); static void jobmgr_dispatch_all(jobmgr_t jm); static job_t jobmgr_new_anonymous(jobmgr_t jm); static job_t job_mig_intran2(jobmgr_t jm, mach_port_t p); Modified: trunk/launchd/src/launchd_core_logic.h =================================================================== --- trunk/launchd/src/launchd_core_logic.h 2007-02-08 22:43:27 UTC (rev 23047) +++ trunk/launchd/src/launchd_core_logic.h 2007-02-08 22:48:29 UTC (rev 23048) @@ -37,7 +37,6 @@ job_t jobmgr_find(jobmgr_t jm, const char *label); void jobmgr_delete_anything_with_port(jobmgr_t jm, mach_port_t port); bool jobmgr_ack_port_destruction(jobmgr_t jm, mach_port_t p); -void jobmgr_remove(jobmgr_t jm); job_t jobmgr_find_by_service_port(jobmgr_t jm, mach_port_t p); launch_data_t job_export_all(void); -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070208/e244cc65/attachment.html From source_changes at macosforge.org Thu Feb 8 15:44:36 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:40 2007 Subject: [launchd-changes] [23049] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070208234436.67D5D49F8FF@cvs.opensource.apple.com> Revision: 23049 http://trac.macosforge.org/projects/launchd/changeset/23049 Author: zarzycki@apple.com Date: 2007-02-08 15:44:35 -0800 (Thu, 08 Feb 2007) Log Message: ----------- Get rid of a false 'Bug' log message. Modified Paths: -------------- trunk/launchd/src/launchd_core_logic.c Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2007-02-08 22:48:29 UTC (rev 23048) +++ trunk/launchd/src/launchd_core_logic.c 2007-02-08 23:44:35 UTC (rev 23049) @@ -789,7 +789,8 @@ free(argv); - if (!job_assumes(j, jr != NULL)) { + /* jobs can easily be denied creation during shutdown */ + if (!jr) { goto out_bad; } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070208/18191aba/attachment.html From source_changes at macosforge.org Thu Feb 8 17:51:31 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:40 2007 Subject: [launchd-changes] [23050] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070209015131.A392E49FA99@cvs.opensource.apple.com> Revision: 23050 http://trac.macosforge.org/projects/launchd/changeset/23050 Author: zarzycki@apple.com Date: 2007-02-08 17:51:31 -0800 (Thu, 08 Feb 2007) Log Message: ----------- Performance hack. We really ought to switch to hashes at some point. Modified Paths: -------------- trunk/launchd/src/launchd_core_logic.c Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2007-02-08 23:44:35 UTC (rev 23049) +++ trunk/launchd/src/launchd_core_logic.c 2007-02-09 01:51:31 UTC (rev 23050) @@ -191,7 +191,7 @@ struct jobmgr_s { SLIST_ENTRY(jobmgr_s) sle; SLIST_HEAD(, jobmgr_s) submgrs; - SLIST_HEAD(, job_s) jobs; + TAILQ_HEAD(, job_s) jobs; mach_port_t jm_port; mach_port_t req_port; jobmgr_t parentmgr; @@ -227,7 +227,7 @@ struct job_s { kq_callback kqjob_callback; - SLIST_ENTRY(job_s) sle; + TAILQ_ENTRY(job_s) sle; SLIST_HEAD(, socketgroup) sockets; SLIST_HEAD(, calendarinterval) cal_intervals; SLIST_HEAD(, envitem) global_env; @@ -523,7 +523,7 @@ jobmgr_shutdown(jmi); } - SLIST_FOREACH_SAFE(ji, &jm->jobs, sle, jn) { + TAILQ_FOREACH_SAFE(ji, &jm->jobs, sle, jn) { if (!job_active(ji)) { job_remove(ji); } else if (!ji->hopefully_exits_last) { @@ -551,10 +551,10 @@ } /* We should have one job left and it should be the anonymous job */ - ji = SLIST_FIRST(&jm->jobs); - jobmgr_assumes(jm, ji && ji == jm->anonj && (SLIST_NEXT(ji, sle) == NULL)); + ji = TAILQ_FIRST(&jm->jobs); + jobmgr_assumes(jm, ji && ji == jm->anonj && (TAILQ_NEXT(ji, sle) == NULL)); - while ((ji = SLIST_FIRST(&jm->jobs))) { + while ((ji = TAILQ_FIRST(&jm->jobs))) { job_remove(ji); } @@ -682,7 +682,7 @@ kevent_mod((uintptr_t)j, EVFILT_TIMER, EV_DELETE, 0, 0, NULL); if (job_assumes(j, j->mgr)) { - SLIST_REMOVE(&j->mgr->jobs, j, job_s, sle); + TAILQ_REMOVE(&j->mgr->jobs, j, sle); jobmgr_tickle(j->mgr); } @@ -972,7 +972,7 @@ j->argv[i] = NULL; } - SLIST_INSERT_HEAD(&jm->jobs, j, sle); + TAILQ_INSERT_TAIL(&jm->jobs, j, sle); job_log(j, LOG_DEBUG, "Conceived"); @@ -1493,7 +1493,7 @@ } } - SLIST_FOREACH(ji, &jm->jobs, sle) { + TAILQ_FOREACH(ji, &jm->jobs, sle) { if (strcmp(ji->label, label) == 0) { return ji; } @@ -1514,15 +1514,17 @@ runtime_get_caller_creds(&ldc); - SLIST_FOREACH(ji, &jm->jobs, sle) { + TAILQ_FOREACH(ji, &jm->jobs, sle) { if (ji->p == ldc.pid) { /* This is just a MRU perfomance hack */ - SLIST_REMOVE(&jm->jobs, ji, job_s, sle); - SLIST_INSERT_HEAD(&jm->jobs, ji, sle); + TAILQ_REMOVE(&jm->jobs, ji, sle); + TAILQ_INSERT_HEAD(&jm->jobs, ji, sle); return ji; + } else if (ji->p == 0) { + /* All the PIDs are at the front of the list */ + break; } } - return jm->anonj; } @@ -1534,7 +1536,7 @@ } } - SLIST_FOREACH(ji, &jm->jobs, sle) { + TAILQ_FOREACH(ji, &jm->jobs, sle) { if (ji->j_port == p) { return ji; } @@ -1566,7 +1568,7 @@ } } - SLIST_FOREACH(ji, &jm->jobs, sle) { + TAILQ_FOREACH(ji, &jm->jobs, sle) { SLIST_FOREACH(ms, &ji->machservices, sle) { if (ms->port == p) { return ji; @@ -1592,7 +1594,7 @@ job_export_all2(jmi, where); } - SLIST_FOREACH(ji, &jm->jobs, sle) { + TAILQ_FOREACH(ji, &jm->jobs, sle) { launch_data_t tmp; if (jobmgr_assumes(jm, (tmp = job_export2(ji, false)) != NULL)) { @@ -1636,6 +1638,10 @@ return; } + /* Performance hack */ + TAILQ_REMOVE(&j->mgr->jobs, j, sle); + TAILQ_INSERT_TAIL(&j->mgr->jobs, j, sle); + job_assumes(j, gettimeofday(&tve, NULL) != -1); if (j->wait_reply_port) { @@ -1698,7 +1704,7 @@ jobmgr_dispatch_all(jmi); } - SLIST_FOREACH_SAFE(ji, &jm->jobs, sle, jn) { + TAILQ_FOREACH_SAFE(ji, &jm->jobs, sle, jn) { job_dispatch(ji, false); } } @@ -1889,6 +1895,10 @@ job_start_child(j); break; default: + /* Performance hack */ + TAILQ_REMOVE(&j->mgr->jobs, j, sle); + TAILQ_INSERT_HEAD(&j->mgr->jobs, j, sle); + if (!j->legacy_mach_job) { job_assumes(j, close(oepair[1]) != -1); } @@ -1993,7 +2003,7 @@ jobmgr_setup_env_from_other_jobs(jm->parentmgr); } - SLIST_FOREACH(ji, &jm->jobs, sle) { + TAILQ_FOREACH(ji, &jm->jobs, sle) { SLIST_FOREACH(ei, &ji->global_env, sle) { setenv(ei->key, ei->value, 1); } @@ -2815,7 +2825,7 @@ unsigned int cnt = 0; job_t ji; - SLIST_FOREACH(ji, &j->mgr->jobs, sle) { + TAILQ_FOREACH(ji, &j->mgr->jobs, sle) { if (ji->p) { cnt++; } @@ -3186,13 +3196,13 @@ return jm; } - SLIST_FOREACH(ji, &jm->jobs, sle) { + TAILQ_FOREACH(ji, &jm->jobs, sle) { if (ji->p && !ji->hopefully_exits_last) { return jm; } } - SLIST_FOREACH(ji, &jm->jobs, sle) { + TAILQ_FOREACH(ji, &jm->jobs, sle) { job_stop(ji); } @@ -3215,7 +3225,7 @@ return false; } - SLIST_FOREACH(ji, &jm->jobs, sle) { + TAILQ_FOREACH(ji, &jm->jobs, sle) { if (ji->p) { return false; } @@ -3306,6 +3316,8 @@ return NULL; } + TAILQ_INIT(&jmr->jobs); + jmr->req_port = requestorport; if ((jmr->parentmgr = jm)) { @@ -3378,7 +3390,7 @@ jobmgr_delete_anything_with_port(jmi, port); } - SLIST_FOREACH_SAFE(ji, &jm->jobs, sle, jn) { + TAILQ_FOREACH_SAFE(ji, &jm->jobs, sle, jn) { SLIST_FOREACH_SAFE(ms, &ji->machservices, sle, next_ms) { if (ms->port == port) { machservice_delete(ms); @@ -3393,7 +3405,7 @@ struct machservice *ms; job_t ji; - SLIST_FOREACH(ji, &jm->jobs, sle) { + TAILQ_FOREACH(ji, &jm->jobs, sle) { SLIST_FOREACH(ms, &ji->machservices, sle) { if (strcmp(name, ms->name) == 0) { return ms; @@ -3551,7 +3563,7 @@ } /* We don't need the _SAFE version because we return after the job_dispatch() */ - SLIST_FOREACH(ji, &jm->jobs, sle) { + TAILQ_FOREACH(ji, &jm->jobs, sle) { SLIST_FOREACH(ms, &ji->machservices, sle) { if (ms->port != p) { continue; @@ -3704,7 +3716,7 @@ jobmgr_dispatch_all_semaphores(jmi); } - SLIST_FOREACH_SAFE(ji, &jm->jobs, sle, jn) { + TAILQ_FOREACH_SAFE(ji, &jm->jobs, sle, jn) { if (!SLIST_EMPTY(&ji->semaphores)) { job_dispatch(ji, false); } @@ -4027,7 +4039,7 @@ *up_cont = MACH_PORT_NULL; - SLIST_FOREACH(ji, &root_jobmgr->jobs, sle) { + TAILQ_FOREACH(ji, &root_jobmgr->jobs, sle) { if (ji->mach_uid != which_user) { continue; } @@ -4248,7 +4260,7 @@ jm = j->mgr; - SLIST_FOREACH(ji, &jm->jobs, sle) { + TAILQ_FOREACH(ji, &jm->jobs, sle) { SLIST_FOREACH(ms, &ji->machservices, sle) { cnt++; } @@ -4268,7 +4280,7 @@ goto out_bad; } - SLIST_FOREACH(ji, &jm->jobs, sle) { + TAILQ_FOREACH(ji, &jm->jobs, sle) { SLIST_FOREACH(ms, &ji->machservices, sle) { strlcpy(service_names[cnt2], machservice_name(ms), sizeof(service_names[0])); service_actives[cnt2] = machservice_status(ms); @@ -4312,8 +4324,8 @@ } if (job_assumes(j, jmi != NULL)) { - SLIST_REMOVE(&j->mgr->jobs, j, job_s, sle); - SLIST_INSERT_HEAD(&jmi->jobs, j, sle); + TAILQ_REMOVE(&j->mgr->jobs, j, sle); + TAILQ_INSERT_TAIL(&jmi->jobs, j, sle); j->mgr = jmi; } } @@ -4651,7 +4663,7 @@ launchd_assert((root_jobmgr = jobmgr_new(NULL, mach_task_self(), checkin_port)) != NULL); - SLIST_FOREACH(ji, &root_jobmgr->jobs, sle) { + TAILQ_FOREACH(ji, &root_jobmgr->jobs, sle) { if (ji->anonymous) { anon_job = ji; break; -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070208/727aea33/attachment.html From source_changes at macosforge.org Fri Feb 9 09:56:22 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:40 2007 Subject: [launchd-changes] [23051] trunk/launchd/src Message-ID: <20070209175622.49A1B4A02DF@cvs.opensource.apple.com> Revision: 23051 http://trac.macosforge.org/projects/launchd/changeset/23051 Author: zarzycki@apple.com Date: 2007-02-09 09:56:21 -0800 (Fri, 09 Feb 2007) Log Message: ----------- Better shutdown debugging. Modified Paths: -------------- trunk/launchd/src/launchd.c trunk/launchd/src/launchd.h trunk/launchd/src/launchd_core_logic.c Modified: trunk/launchd/src/launchd.c =================================================================== --- trunk/launchd/src/launchd.c 2007-02-09 01:51:31 UTC (rev 23050) +++ trunk/launchd/src/launchd.c 2007-02-09 17:56:21 UTC (rev 23051) @@ -394,28 +394,26 @@ void launchd_shutdown(void) { + struct stat sb; + if (shutdown_in_progress) { return; } shutdown_in_progress = true; -#if 0 - struct stat sb; + if (getpid() == 1) { + if (stat("/var/db/debugShutdownHangs", &sb) != -1) { + /* + * When this changes to a more sustainable API, update this: + * http://howto.apple.com/db.cgi?Debugging_Apps_Non-Responsive_At_Shutdown + */ + debug_shutdown_hangs = true; + } - if (stat("/var/db/debugShutdownHangs", &sb) != -1) { - /* - * When this changes to a more sustainable API, update this: - * http://howto.apple.com/db.cgi?Debugging_Apps_Non-Responsive_At_Shutdown - */ - debug_shutdown_hangs = true; - } -#else - if (getpid() == 1) { launchd_assumes(kevent_mod((uintptr_t)debugshutdown_callback, EVFILT_TIMER, EV_ADD|EV_ONESHOT, NOTE_SECONDS, 5, &kqdebugshutdown_callback) != -1); } -#endif rlcj = NULL; @@ -654,6 +652,9 @@ pid_t sddp; if (launchd_assumes(posix_spawn(&sddp, sdd_args[0], NULL, NULL, sdd_args, environ) == 0)) { - launchd_assumes(kevent_mod(sddp, EVFILT_PROC, EV_ADD, NOTE_EXIT, 0, &kqsimple_zombie_reaper) != -1); + int wstatus; + + /* No bootstrap port was given. It is safe to block. */ + launchd_assumes(waitpid(sddp, &wstatus, 0) != -1); } } Modified: trunk/launchd/src/launchd.h =================================================================== --- trunk/launchd/src/launchd.h 2007-02-09 01:51:31 UTC (rev 23050) +++ trunk/launchd/src/launchd.h 2007-02-09 17:56:21 UTC (rev 23051) @@ -31,7 +31,6 @@ struct kevent; struct conncb; -extern kq_callback kqsimple_zombie_reaper; extern sigset_t blocked_signals; extern bool debug_shutdown_hangs; extern bool network_up; Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2007-02-09 01:51:31 UTC (rev 23050) +++ trunk/launchd/src/launchd_core_logic.c 2007-02-09 17:56:21 UTC (rev 23051) @@ -337,22 +337,12 @@ static bool cronemu_hour(struct tm *wtm, int hour, int min); static bool cronemu_min(struct tm *wtm, int min); -static void simple_zombie_reaper(void *, struct kevent *); - -kq_callback kqsimple_zombie_reaper = simple_zombie_reaper; - static int dir_has_files(job_t j, const char *path); static char **mach_cmd2argv(const char *string); jobmgr_t root_jobmgr; jobmgr_t gc_this_jobmgr; void -simple_zombie_reaper(void *obj __attribute__((unused)), struct kevent *kev) -{ - waitpid(kev->ident, NULL, 0); -} - -void job_ignore(job_t j) { struct semaphoreitem *si; @@ -1779,9 +1769,7 @@ if ((uintptr_t)j == kev->ident || (uintptr_t)&j->start_interval == kev->ident) { job_dispatch(j, true); } else if ((uintptr_t)&j->exit_timeout == kev->ident) { - if (debug_shutdown_hangs) { - job_force_sampletool(j); - } + job_force_sampletool(j); job_log(j, LOG_WARNING, "Exit timeout elapsed (%u seconds). Killing.", j->exit_timeout); job_assumes(j, kill(j->p, SIGKILL) != -1); } else { @@ -3625,16 +3613,72 @@ void job_force_sampletool(job_t j) { - char *sample_args[] = { "sample", NULL, "1", "-mayDie", NULL }; + struct stat sb; + char logfile[PATH_MAX]; char pidstr[100]; + char *sample_args[] = { "sample", pidstr, "1", "-mayDie", "-file", logfile, NULL }; + char *contents = NULL; + int logfile_fd = -1; + int console_fd = -1; pid_t sp; + + if (!debug_shutdown_hangs) { + return; + } snprintf(pidstr, sizeof(pidstr), "%u", j->p); - sample_args[1] = pidstr; + snprintf(logfile, sizeof(logfile), "/var/log/shutdown/%s-%u.sample.txt", j->label, j->p); - 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); + job_assumes(j, mkdir("/var/log/shutdown", S_IRWXU) != -1 || errno == EEXIST); + + /* + * This will stall launchd for as long as the 'sample' tool runs. + * + * We didn't give the 'sample' tool a bootstrap port, so it therefore + * can't deadlock against launchd. + */ + if (job_assumes(j, (errno = posix_spawnp(&sp, sample_args[0], NULL, NULL, sample_args, environ)) == 0)) { + int wstatus; + + job_assumes(j, waitpid(sp, &wstatus, 0) != -1); } + + if (!job_assumes(j, (logfile_fd = open(logfile, O_RDONLY|O_NOCTTY)) != -1)) { + goto out; + } + + if (!job_assumes(j, (console_fd = open(_PATH_CONSOLE, O_WRONLY|O_APPEND||O_NOCTTY)) != -1)) { + goto out; + } + + if (!job_assumes(j, fstat(logfile_fd, &sb) != -1)) { + goto out; + } + + contents = malloc(sb.st_size); + + if (!job_assumes(j, contents != NULL)) { + goto out; + } + + if (!job_assumes(j, read(logfile_fd, contents, sb.st_size) == sb.st_size)) { + goto out; + } + + job_assumes(j, write(console_fd, contents, sb.st_size) == sb.st_size); + +out: + if (contents) { + free(contents); + } + + if (logfile_fd != -1) { + job_assumes(j, close(logfile_fd) != -1); + } + + if (console_fd != -1) { + job_assumes(j, close(console_fd) != -1); + } } bool -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070209/2dc67e91/attachment.html From source_changes at macosforge.org Fri Feb 9 14:31:37 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:40 2007 Subject: [launchd-changes] [23052] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070209223137.446A64A084D@cvs.opensource.apple.com> Revision: 23052 http://trac.macosforge.org/projects/launchd/changeset/23052 Author: zarzycki@apple.com Date: 2007-02-09 14:31:36 -0800 (Fri, 09 Feb 2007) Log Message: ----------- Even better shutdown debugging. Modified Paths: -------------- trunk/launchd/src/launchd_core_logic.c Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2007-02-09 17:56:21 UTC (rev 23051) +++ trunk/launchd/src/launchd_core_logic.c 2007-02-09 22:31:36 UTC (rev 23052) @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -199,6 +200,7 @@ char *jm_stdout; char *jm_stderr; unsigned int global_on_demand_cnt; + unsigned int would_have_sigkilled; unsigned int transfer_bstrap:1, sent_stop_to_hopeful_jobs:1, shutting_down:1; char name[0]; }; @@ -209,6 +211,7 @@ static jobmgr_t jobmgr_new(jobmgr_t jm, mach_port_t requestorport, mach_port_t checkin_port); static jobmgr_t jobmgr_parent(jobmgr_t jm); static jobmgr_t jobmgr_tickle(jobmgr_t jm); +static void jobmgr_log_stray_children(jobmgr_t jm); static void jobmgr_remove(jobmgr_t jm); static void jobmgr_dispatch_all(jobmgr_t jm); static job_t jobmgr_new_anonymous(jobmgr_t jm); @@ -305,6 +308,7 @@ static const char *job_prog(job_t j); static pid_t job_get_pid(job_t j); static jobmgr_t job_get_bs(job_t j); +static void job_kill(job_t j); static void job_uncork_fork(job_t j); static void job_log_stdouterr(job_t j); static void job_logv(job_t j, int pri, int err, const char *msg, va_list ap); @@ -337,6 +341,7 @@ static bool cronemu_hour(struct tm *wtm, int hour, int min); static bool cronemu_min(struct tm *wtm, int min); +static unsigned int total_children; static int dir_has_files(job_t j, const char *path); static char **mach_cmd2argv(const char *string); jobmgr_t root_jobmgr; @@ -1628,6 +1633,8 @@ return; } + total_children--; + /* Performance hack */ TAILQ_REMOVE(&j->mgr->jobs, j, sle); TAILQ_INSERT_TAIL(&j->mgr->jobs, j, sle); @@ -1756,6 +1763,19 @@ } void +job_kill(job_t j) +{ + if (debug_shutdown_hangs) { + j->mgr->would_have_sigkilled++; + if (j->mgr->would_have_sigkilled >= total_children) { + job_assumes(j, host_reboot(mach_host_self(), HOST_REBOOT_DEBUGGER) == 0); + } + } else { + job_assumes(j, kill(j->p, SIGKILL) != -1); + } +} + +void job_callback(void *obj, struct kevent *kev) { job_t j = obj; @@ -1771,7 +1791,7 @@ } else if ((uintptr_t)&j->exit_timeout == kev->ident) { job_force_sampletool(j); job_log(j, LOG_WARNING, "Exit timeout elapsed (%u seconds). Killing.", j->exit_timeout); - job_assumes(j, kill(j->p, SIGKILL) != -1); + job_kill(j); } else { calendarinterval_callback(j, kev); } @@ -1883,6 +1903,8 @@ job_start_child(j); break; default: + total_children++; + /* Performance hack */ TAILQ_REMOVE(&j->mgr->jobs, j, sle); TAILQ_INSERT_HEAD(&j->mgr->jobs, j, sle); @@ -2810,16 +2832,7 @@ job_log(j, LOG_INFO, "Exited. Was only configured to run once."); return true; } else if (j->mgr->shutting_down) { - unsigned int cnt = 0; - job_t ji; - - TAILQ_FOREACH(ji, &j->mgr->jobs, sle) { - if (ji->p) { - cnt++; - } - } - - job_log(j, LOG_INFO, "Exited while shutdown in progress. Processes remaining: %u", cnt); + job_log(j, LOG_NOTICE, "Exited while shutdown in progress. Processes remaining: %u", total_children); return true; } else if (!j->checkedin && (!SLIST_EMPTY(&j->sockets) || !SLIST_EMPTY(&j->machservices))) { job_log(j, LOG_WARNING, "Failed to check-in!"); @@ -3197,6 +3210,7 @@ jm->sent_stop_to_hopeful_jobs = true; if (jobmgr_is_idle(jm)) { + jobmgr_log_stray_children(jm); jobmgr_remove(jm); return NULL; } @@ -3204,6 +3218,42 @@ return jm; } +void +jobmgr_log_stray_children(jobmgr_t jm) +{ + int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_ALL }; + size_t i, kp_cnt, len = 10*1024*1024; + struct kinfo_proc *kp; + + if (jm->parentmgr || getpid() != 1) { + return; + } + + if (!jobmgr_assumes(jm, (kp = malloc(len)) != NULL)) { + return; + } + if (!jobmgr_assumes(jm, sysctl(mib, 3, kp, &len, NULL, 0) != -1)) { + goto out; + } + + kp_cnt = len / sizeof(struct kinfo_proc); + + for (i = 0; i < kp_cnt; i++) { + pid_t p_i = kp[i].kp_proc.p_pid; + pid_t pp_i = kp[i].kp_eproc.e_ppid; + + if (p_i == 0 || p_i == 1) { + continue; + } + + jobmgr_log(jm, LOG_WARNING, "Stray process at shutdown: PID %u PPID %u %s", p_i, pp_i, kp[i].kp_proc.p_comm); + jobmgr_assumes(jm, kill(p_i, SIGKILL) != -1); + } + +out: + free(kp); +} + bool jobmgr_is_idle(jobmgr_t jm) { -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070209/3ce0759e/attachment.html From source_changes at macosforge.org Fri Feb 9 14:51:16 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:40 2007 Subject: [launchd-changes] [23053] trunk/launchd/src Message-ID: <20070209225116.C7DAC4A08AD@cvs.opensource.apple.com> Revision: 23053 http://trac.macosforge.org/projects/launchd/changeset/23053 Author: zarzycki@apple.com Date: 2007-02-09 14:51:16 -0800 (Fri, 09 Feb 2007) Log Message: ----------- Move call to exit() and reboot() to jobmgr_remove(root_jobmgr). Modified Paths: -------------- trunk/launchd/src/launchd.c trunk/launchd/src/launchd_core_logic.c trunk/launchd/src/launchd_core_logic.h Modified: trunk/launchd/src/launchd.c =================================================================== --- trunk/launchd/src/launchd.c 2007-02-09 22:31:36 UTC (rev 23052) +++ trunk/launchd/src/launchd.c 2007-02-09 22:51:16 UTC (rev 23053) @@ -417,7 +417,7 @@ rlcj = NULL; - root_jobmgr = jobmgr_shutdown(root_jobmgr); + launchd_assert(jobmgr_shutdown(root_jobmgr) != NULL); } void @@ -624,7 +624,8 @@ void launchd_post_kevent(void) { - if (shutdown_in_progress && (!root_jobmgr || jobmgr_is_idle(root_jobmgr))) { +#if 0 + if (shutdown_in_progress && jobmgr_is_idle(root_jobmgr)) { shutdown_in_progress = false; if (getpid() == 1) { @@ -632,11 +633,9 @@ 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); } } +#endif if (getpid() == 1) { if (rlcj && job_active(rlcj)) { return; Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2007-02-09 22:31:36 UTC (rev 23052) +++ trunk/launchd/src/launchd_core_logic.c 2007-02-09 22:51:16 UTC (rev 23053) @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -211,6 +212,7 @@ static jobmgr_t jobmgr_new(jobmgr_t jm, mach_port_t requestorport, mach_port_t checkin_port); static jobmgr_t jobmgr_parent(jobmgr_t jm); static jobmgr_t jobmgr_tickle(jobmgr_t jm); +static bool jobmgr_is_idle(jobmgr_t jm); static void jobmgr_log_stray_children(jobmgr_t jm); static void jobmgr_remove(jobmgr_t jm); static void jobmgr_dispatch_all(jobmgr_t jm); @@ -576,6 +578,10 @@ if (jm->parentmgr) { SLIST_REMOVE(&jm->parentmgr->submgrs, jm, jobmgr_s, sle); jobmgr_tickle(jm->parentmgr); + } else if (getpid() == 1) { + jobmgr_assumes(jm, reboot(RB_HALT) != -1); + } else { + exit(EXIT_SUCCESS); } free(jm); Modified: trunk/launchd/src/launchd_core_logic.h =================================================================== --- trunk/launchd/src/launchd_core_logic.h 2007-02-09 22:31:36 UTC (rev 23052) +++ trunk/launchd/src/launchd_core_logic.h 2007-02-09 22:51:16 UTC (rev 23053) @@ -31,7 +31,6 @@ void jobmgr_set_stdout(jobmgr_t jm, const char *what); void jobmgr_set_stderr(jobmgr_t jm, const char *what); -bool jobmgr_is_idle(jobmgr_t jm); jobmgr_t jobmgr_shutdown(jobmgr_t jm); void jobmgr_dispatch_all_semaphores(jobmgr_t jm); job_t jobmgr_find(jobmgr_t jm, const char *label); -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070209/626554a0/attachment.html From source_changes at macosforge.org Fri Feb 9 19:25:35 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:40 2007 Subject: [launchd-changes] [23054] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070210032535.5121C4A1992@cvs.opensource.apple.com> Revision: 23054 http://trac.macosforge.org/projects/launchd/changeset/23054 Author: zarzycki@apple.com Date: 2007-02-09 19:25:34 -0800 (Fri, 09 Feb 2007) Log Message: ----------- Misc Modified Paths: -------------- trunk/launchd/src/launchd_core_logic.c Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2007-02-09 22:51:16 UTC (rev 23053) +++ trunk/launchd/src/launchd_core_logic.c 2007-02-10 03:25:34 UTC (rev 23054) @@ -201,7 +201,6 @@ char *jm_stdout; char *jm_stderr; unsigned int global_on_demand_cnt; - unsigned int would_have_sigkilled; unsigned int transfer_bstrap:1, sent_stop_to_hopeful_jobs:1, shutting_down:1; char name[0]; }; @@ -1771,14 +1770,7 @@ void job_kill(job_t j) { - if (debug_shutdown_hangs) { - j->mgr->would_have_sigkilled++; - if (j->mgr->would_have_sigkilled >= total_children) { - job_assumes(j, host_reboot(mach_host_self(), HOST_REBOOT_DEBUGGER) == 0); - } - } else { - job_assumes(j, kill(j->p, SIGKILL) != -1); - } + job_assumes(j, kill(j->p, SIGKILL) != -1); } void @@ -1788,8 +1780,13 @@ switch (kev->filter) { case EVFILT_PROC: - job_reap(j); - job_dispatch(j, false); + if (kev->fflags & NOTE_EXEC) { + job_log(j, LOG_DEBUG, "Called execve()"); + } + if (kev->fflags & NOTE_EXIT) { + job_reap(j); + job_dispatch(j, false); + } break; case EVFILT_TIMER: if ((uintptr_t)j == kev->ident || (uintptr_t)&j->start_interval == kev->ident) { @@ -1925,7 +1922,7 @@ job_assumes(j, close(spair[1]) == 0); ipc_open(_fd(spair[0]), j); } - if (kevent_mod(c, EVFILT_PROC, EV_ADD, NOTE_EXIT, 0, &j->kqjob_callback) == -1) { + if (kevent_mod(c, EVFILT_PROC, EV_ADD, NOTE_EXEC|NOTE_EXIT, 0, &j->kqjob_callback) == -1) { job_log_error(j, LOG_ERR, "kevent()"); job_reap(j); } else { @@ -3501,13 +3498,8 @@ void machservice_delete(struct machservice *ms) { - if (ms->recv) { - if (ms->isActive) { - /* FIXME we should cancel the notification */ - job_log(ms->job, LOG_DEBUG, "Mach service deleted while we didn't own the receive right: %s", ms->name); - } else { - job_assumes(ms->job, launchd_mport_close_recv(ms->port) == KERN_SUCCESS); - } + if (ms->recv && job_assumes(ms->job, !ms->isActive)) { + job_assumes(ms->job, launchd_mport_close_recv(ms->port) == KERN_SUCCESS); } job_assumes(ms->job, launchd_mport_deallocate(ms->port) == KERN_SUCCESS); -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070209/a8a6798b/attachment.html From source_changes at macosforge.org Sat Feb 10 08:52:04 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:40 2007 Subject: [launchd-changes] [23055] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070210165204.D69514A22F6@cvs.opensource.apple.com> Revision: 23055 http://trac.macosforge.org/projects/launchd/changeset/23055 Author: zarzycki@apple.com Date: 2007-02-10 08:52:04 -0800 (Sat, 10 Feb 2007) Log Message: ----------- Minor bug fixes. Modified Paths: -------------- trunk/launchd/src/launchd_core_logic.c Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2007-02-10 03:25:34 UTC (rev 23054) +++ trunk/launchd/src/launchd_core_logic.c 2007-02-10 16:52:04 UTC (rev 23055) @@ -3668,6 +3668,7 @@ char *contents = NULL; int logfile_fd = -1; int console_fd = -1; + int wstatus; pid_t sp; if (!debug_shutdown_hangs) { @@ -3685,17 +3686,23 @@ * We didn't give the 'sample' tool a bootstrap port, so it therefore * can't deadlock against launchd. */ - if (job_assumes(j, (errno = posix_spawnp(&sp, sample_args[0], NULL, NULL, sample_args, environ)) == 0)) { - int wstatus; + if (!job_assumes(j, (errno = posix_spawnp(&sp, sample_args[0], NULL, NULL, sample_args, environ)) == 0)) { + goto out; + } - job_assumes(j, waitpid(sp, &wstatus, 0) != -1); + if (!job_assumes(j, waitpid(sp, &wstatus, 0) != -1)) { + goto out; } + if (!job_assumes(j, WIFEXITED(wstatus) && WEXITSTATUS(wstatus) == 0)) { + goto out; + } + if (!job_assumes(j, (logfile_fd = open(logfile, O_RDONLY|O_NOCTTY)) != -1)) { goto out; } - if (!job_assumes(j, (console_fd = open(_PATH_CONSOLE, O_WRONLY|O_APPEND||O_NOCTTY)) != -1)) { + if (!job_assumes(j, (console_fd = open(_PATH_CONSOLE, O_WRONLY|O_APPEND|O_NOCTTY)) != -1)) { goto out; } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070210/808780b6/attachment.html From source_changes at macosforge.org Sun Feb 11 21:08:02 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:40 2007 Subject: [launchd-changes] [23056] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070212050802.10CD94A33E6@cvs.opensource.apple.com> Revision: 23056 http://trac.macosforge.org/projects/launchd/changeset/23056 Author: zarzycki@apple.com Date: 2007-02-11 21:08:01 -0800 (Sun, 11 Feb 2007) Log Message: ----------- kqueue dispatch clean up. Modified Paths: -------------- trunk/launchd/src/launchd_core_logic.c Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2007-02-10 16:52:04 UTC (rev 23055) +++ trunk/launchd/src/launchd_core_logic.c 2007-02-12 05:08:01 UTC (rev 23056) @@ -129,7 +129,7 @@ static void socketgroup_delete(job_t j, struct socketgroup *sg); static void socketgroup_watch(job_t j, struct socketgroup *sg); static void socketgroup_ignore(job_t j, struct socketgroup *sg); -static void socketgroup_callback(job_t j, struct kevent *kev); +static void socketgroup_callback(job_t j); static void socketgroup_setup(launch_data_t obj, const char *key, void *context); struct calendarinterval { @@ -141,7 +141,7 @@ static bool calendarinterval_new_from_obj(job_t j, launch_data_t obj); static void calendarinterval_delete(job_t j, struct calendarinterval *ci); static void calendarinterval_setalarm(job_t j, struct calendarinterval *ci); -static void calendarinterval_callback(job_t j, struct kevent *kev); +static void calendarinterval_callback(job_t j, void *ident); struct envitem { SLIST_ENTRY(envitem) sle; @@ -303,6 +303,9 @@ static void job_force_sampletool(job_t j); static void job_reparent_hack(job_t j, const char *where); static void job_callback(void *obj, struct kevent *kev); +static void job_callback_proc(job_t j, int fflags); +static void job_callback_timer(job_t j, void *ident); +static void job_callback_read(job_t j, int ident); static launch_data_t job_export2(job_t j, bool subjobs); static job_t job_new_spawn(job_t j, const char *label, const char *path, const char *workingdir, const char *const *argv, const char *const *env, mode_t *u_mask, bool w4d); static job_t job_new_via_mach_init(job_t j, const char *cmd, uid_t uid, bool ond); @@ -1774,47 +1777,60 @@ } void +job_callback_proc(job_t j, int fflags) +{ + if (fflags & NOTE_EXEC) { + job_log(j, LOG_DEBUG, "Called execve()"); + } + + if (fflags & NOTE_EXIT) { + job_reap(j); + job_dispatch(j, false); + } +} + +void +job_callback_timer(job_t j, void *ident) +{ + if (j == ident || &j->start_interval == ident) { + job_dispatch(j, true); + } else if (&j->exit_timeout == ident) { + job_force_sampletool(j); + job_log(j, LOG_WARNING, "Exit timeout elapsed (%u seconds). Killing.", j->exit_timeout); + job_kill(j); + } else { + calendarinterval_callback(j, ident); + } +} + +void +job_callback_read(job_t j, int ident) +{ + if (ident == j->log_redirect_fd) { + job_log_stdouterr(j); + } else { + socketgroup_callback(j); + } +} + +void job_callback(void *obj, struct kevent *kev) { job_t j = obj; switch (kev->filter) { case EVFILT_PROC: - if (kev->fflags & NOTE_EXEC) { - job_log(j, LOG_DEBUG, "Called execve()"); - } - if (kev->fflags & NOTE_EXIT) { - job_reap(j); - job_dispatch(j, false); - } - break; + return job_callback_proc(j, kev->fflags); case EVFILT_TIMER: - if ((uintptr_t)j == kev->ident || (uintptr_t)&j->start_interval == kev->ident) { - job_dispatch(j, true); - } else if ((uintptr_t)&j->exit_timeout == kev->ident) { - job_force_sampletool(j); - job_log(j, LOG_WARNING, "Exit timeout elapsed (%u seconds). Killing.", j->exit_timeout); - job_kill(j); - } else { - calendarinterval_callback(j, kev); - } - break; + return job_callback_timer(j, (void *)kev->ident); case EVFILT_VNODE: - semaphoreitem_callback(j, kev); - break; + return semaphoreitem_callback(j, kev); case EVFILT_READ: - if (kev->ident == (uintptr_t)j->log_redirect_fd) { - job_log_stdouterr(j); - } else { - socketgroup_callback(j, kev); - } - break; + return job_callback_read(j, kev->ident); case EVFILT_MACHPORT: - job_dispatch(j, true); - break; + return (void)job_dispatch(j, true); default: - job_assumes(j, false); - break; + return (void)job_assumes(j, false); } } @@ -2607,12 +2623,12 @@ } void -calendarinterval_callback(job_t j, struct kevent *kev) +calendarinterval_callback(job_t j, void *ident) { struct calendarinterval *ci; SLIST_FOREACH(ci, &j->cal_intervals, sle) { - if ((uintptr_t)ci == kev->ident) { + if (ci == ident) { break; } } @@ -2704,7 +2720,7 @@ } void -socketgroup_callback(job_t j, struct kevent *kev) +socketgroup_callback(job_t j) { job_dispatch(j, true); } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070211/03a56efe/attachment.html From source_changes at macosforge.org Sun Feb 11 21:21:36 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:40 2007 Subject: [launchd-changes] [23057] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070212052136.C8D884A33F7@cvs.opensource.apple.com> Revision: 23057 http://trac.macosforge.org/projects/launchd/changeset/23057 Author: zarzycki@apple.com Date: 2007-02-11 21:21:36 -0800 (Sun, 11 Feb 2007) Log Message: ----------- Bug: launchd_core_logic.c:604 (23046):3: j->p == 0 Modified Paths: -------------- trunk/launchd/src/launchd_core_logic.c Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2007-02-12 05:08:01 UTC (rev 23056) +++ trunk/launchd/src/launchd_core_logic.c 2007-02-12 05:21:36 UTC (rev 23057) @@ -273,7 +273,7 @@ importing_global_env:1, importing_hard_limits:1, setmask:1, legacy_mach_job:1, runatload:1; mode_t mask; unsigned int globargv:1, wait4debugger:1, unload_at_exit:1, stall_before_exec:1, only_once:1, - currently_ignored:1, forced_peers_to_demand_mode:1, setnice:1, hopefully_exits_last:1; + currently_ignored:1, forced_peers_to_demand_mode:1, setnice:1, hopefully_exits_last:1, removal_pending:1; char label[0]; }; @@ -599,17 +599,21 @@ struct machservice *ms; struct semaphoreitem *si; - job_log(j, LOG_DEBUG, "Removed"); + if (j->p) { + job_log(j, LOG_DEBUG, "Removal pended until the job exits."); + if (!j->removal_pending) { + j->removal_pending = true; + job_stop(j); + } + + return; + } + if (j->forced_peers_to_demand_mode) { job_set_global_on_demand(j, false); } - if (!job_assumes(j, j->p == 0)) { - job_assumes(j, kill(j->p, SIGKILL) != -1); - job_reap(j); - } - if (!job_assumes(j, j->forkfd == 0)) { job_assumes(j, close(j->forkfd) != -1); } @@ -689,6 +693,8 @@ jobmgr_tickle(j->mgr); } + job_log(j, LOG_DEBUG, "Removed"); + free(j); } @@ -2850,6 +2856,9 @@ } job_log(j, LOG_INFO, "Exited. Was only configured to run once."); return true; + } else if (j->removal_pending) { + job_log(j, LOG_DEBUG, "Exited while removal was pending."); + return true; } else if (j->mgr->shutting_down) { job_log(j, LOG_NOTICE, "Exited while shutdown in progress. Processes remaining: %u", total_children); return true; -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070211/a125cff0/attachment.html From source_changes at macosforge.org Tue Feb 13 13:39:11 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:40 2007 Subject: [launchd-changes] [23058] tags/launchd-194/ Message-ID: <20070213213911.F41E54A59F4@cvs.opensource.apple.com> Revision: 23058 http://trac.macosforge.org/projects/launchd/changeset/23058 Author: zarzycki@apple.com Date: 2007-02-13 13:39:11 -0800 (Tue, 13 Feb 2007) Log Message: ----------- "Tagging launchd-194 from https://svn.macosforge.org/repository/launchd/trunk" Added Paths: ----------- tags/launchd-194/ Copied: tags/launchd-194 (from rev 23057, trunk) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070213/5e4012b0/attachment.html From source_changes at macosforge.org Tue Feb 13 17:42:51 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:40 2007 Subject: [launchd-changes] [23059] trunk/launchd/src Message-ID: <20070214014251.E75904A5D70@cvs.opensource.apple.com> Revision: 23059 http://trac.macosforge.org/projects/launchd/changeset/23059 Author: zarzycki@apple.com Date: 2007-02-13 17:42:50 -0800 (Tue, 13 Feb 2007) Log Message: ----------- More logging. Modified Paths: -------------- trunk/launchd/src/launchd_core_logic.c trunk/launchd/src/launchd_runtime.c Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2007-02-13 21:39:11 UTC (rev 23058) +++ trunk/launchd/src/launchd_core_logic.c 2007-02-14 01:42:50 UTC (rev 23059) @@ -362,6 +362,8 @@ return; } + job_log(j, LOG_DEBUG, "Ignoring..."); + j->currently_ignored = true; SLIST_FOREACH(sg, &j->sockets, sle) { @@ -388,6 +390,8 @@ return; } + job_log(j, LOG_DEBUG, "Watching..."); + j->currently_ignored = false; SLIST_FOREACH(sg, &j->sockets, sle) { @@ -1735,11 +1739,17 @@ if (job_useless(j)) { job_remove(j); return NULL; - } else if (kickstart || job_keepalive(j)) { + } else if (kickstart) { + job_log(j, LOG_DEBUG, "Kick-starting."); job_start(j); + } else if (job_keepalive(j)) { + job_log(j, LOG_DEBUG, "Keeping alive..."); + job_start(j); } else { job_watch(j); } + } else { + job_log(j, LOG_DEBUG, "Tried to dispatch an already active job."); } return j; @@ -1824,6 +1834,9 @@ { job_t j = obj; + job_log(j, LOG_DEBUG, "kev.ident = 0x%lx kev.filter = 0x%x kev->flags = 0x%x kev.fflags = 0x%x kev.data = 0x%lx kev.udata = %p", + kev->ident, kev->filter, kev->flags, kev->fflags, kev->data, kev->udata); + switch (kev->filter) { case EVFILT_PROC: return job_callback_proc(j, kev->fflags); @@ -2900,8 +2913,9 @@ SLIST_FOREACH(ms, &j->machservices, sle) { statusCnt = MACH_PORT_RECEIVE_STATUS_COUNT; if (mach_port_get_attributes(mach_task_self(), ms->port, MACH_PORT_RECEIVE_STATUS, - (mach_port_info_t)&status, &statusCnt) != KERN_SUCCESS) + (mach_port_info_t)&status, &statusCnt) != KERN_SUCCESS) { continue; + } if (status.mps_msgcount) { job_log(j, LOG_DEBUG, "KeepAlive check: job restarted due to %d queued Mach messages on service: %s", status.mps_msgcount, ms->name); Modified: trunk/launchd/src/launchd_runtime.c =================================================================== --- trunk/launchd/src/launchd_runtime.c 2007-02-13 21:39:11 UTC (rev 23058) +++ trunk/launchd/src/launchd_runtime.c 2007-02-14 01:42:50 UTC (rev 23059) @@ -165,7 +165,9 @@ } if (status.mps_msgcount) { EV_SET(&kev, members[i], EVFILT_MACHPORT, 0, 0, 0, jobmgr_find_by_service_port(root_jobmgr, members[i])); - (*((kq_callback *)kev.udata))(kev.udata, &kev); + if (launchd_assumes(kev.udata != NULL)) { + (*((kq_callback *)kev.udata))(kev.udata, &kev); + } /* the callback may have tainted our ability to continue this for loop */ break; } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070213/8a7ad510/attachment.html From source_changes at macosforge.org Tue Feb 13 17:52:08 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:40 2007 Subject: [launchd-changes] [23060] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070214015208.D427B4A5D9C@cvs.opensource.apple.com> Revision: 23060 http://trac.macosforge.org/projects/launchd/changeset/23060 Author: zarzycki@apple.com Date: 2007-02-13 17:52:08 -0800 (Tue, 13 Feb 2007) Log Message: ----------- Let the stdout/sterr pipe linger longer for GUI applications Modified Paths: -------------- trunk/launchd/src/launchd_core_logic.c Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2007-02-14 01:42:50 UTC (rev 23059) +++ trunk/launchd/src/launchd_core_logic.c 2007-02-14 01:52:08 UTC (rev 23060) @@ -273,7 +273,8 @@ importing_global_env:1, importing_hard_limits:1, setmask:1, legacy_mach_job:1, runatload:1; mode_t mask; unsigned int globargv:1, wait4debugger:1, unload_at_exit:1, stall_before_exec:1, only_once:1, - currently_ignored:1, forced_peers_to_demand_mode:1, setnice:1, hopefully_exits_last:1, removal_pending:1; + currently_ignored:1, forced_peers_to_demand_mode:1, setnice:1, hopefully_exits_last:1, removal_pending:1, + wait4pipe_eof:1; char label[0]; }; @@ -869,6 +870,7 @@ } jr->unload_at_exit = true; + jr->wait4pipe_eof = true; jr->stall_before_exec = w4d; if (workingdir) { @@ -1637,7 +1639,7 @@ job_log(j, LOG_DEBUG, "Reaping"); - if (j->log_redirect_fd) { + if (j->log_redirect_fd && !j->wait4pipe_eof) { job_assumes(j, close(j->log_redirect_fd) != -1); j->log_redirect_fd = 0; } @@ -1773,6 +1775,7 @@ job_log(j, LOG_DEBUG, "Standard out/error pipe closed"); job_assumes(j, close(j->log_redirect_fd) != -1); j->log_redirect_fd = 0; + job_dispatch(j, false); } else if (job_assumes(j, rsz != -1)) { buf[rsz] = '\0'; @@ -2996,6 +2999,10 @@ return true; } + if (j->wait4pipe_eof && j->log_redirect_fd) { + return true; + } + if (j->p) { return true; } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070213/3cb1edfb/attachment.html From source_changes at macosforge.org Wed Feb 14 09:09:19 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:40 2007 Subject: [launchd-changes] [23061] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070214170919.1CBD54A6669@cvs.opensource.apple.com> Revision: 23061 http://trac.macosforge.org/projects/launchd/changeset/23061 Author: zarzycki@apple.com Date: 2007-02-14 09:09:18 -0800 (Wed, 14 Feb 2007) Log Message: ----------- postfix doesn't deliver until shutdown Modified Paths: -------------- trunk/launchd/src/launchd_core_logic.c Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2007-02-14 01:52:08 UTC (rev 23060) +++ trunk/launchd/src/launchd_core_logic.c 2007-02-14 17:09:18 UTC (rev 23061) @@ -2521,6 +2521,7 @@ case PATH_MISSING: fflags = NOTE_DELETE|NOTE_RENAME; break; + case DIR_NOT_EMPTY: case PATH_CHANGES: fflags = NOTE_DELETE|NOTE_RENAME|NOTE_REVOKE|NOTE_EXTEND|NOTE_WRITE|NOTE_ATTRIB|NOTE_LINK; break; @@ -2550,6 +2551,7 @@ case PATH_CHANGES: case PATH_EXISTS: case PATH_MISSING: + case DIR_NOT_EMPTY: break; default: continue; -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070214/6b3b58fd/attachment.html From source_changes at macosforge.org Wed Feb 14 11:41:32 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:40 2007 Subject: [launchd-changes] [23062] trunk/launchd/src Message-ID: <20070214194132.16C3C4A6A26@cvs.opensource.apple.com> Revision: 23062 http://trac.macosforge.org/projects/launchd/changeset/23062 Author: zarzycki@apple.com Date: 2007-02-14 11:41:31 -0800 (Wed, 14 Feb 2007) Log Message: ----------- Mega kevent debugging. Modified Paths: -------------- trunk/launchd/src/launchd_core_logic.c trunk/launchd/src/launchd_runtime.c Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2007-02-14 17:09:18 UTC (rev 23061) +++ trunk/launchd/src/launchd_core_logic.c 2007-02-14 19:41:31 UTC (rev 23062) @@ -1837,8 +1837,7 @@ { job_t j = obj; - job_log(j, LOG_DEBUG, "kev.ident = 0x%lx kev.filter = 0x%x kev->flags = 0x%x kev.fflags = 0x%x kev.data = 0x%lx kev.udata = %p", - kev->ident, kev->filter, kev->flags, kev->fflags, kev->data, kev->udata); + job_log(j, LOG_DEBUG, "Dispatching kevent callback."); switch (kev->filter) { case EVFILT_PROC: Modified: trunk/launchd/src/launchd_runtime.c =================================================================== --- trunk/launchd/src/launchd_runtime.c 2007-02-14 17:09:18 UTC (rev 23061) +++ trunk/launchd/src/launchd_runtime.c 2007-02-14 19:41:31 UTC (rev 23062) @@ -143,6 +143,197 @@ return NULL; } +static void +log_kevent_struct(int level, struct kevent *kev) +{ + const char *filter_str; + char ident_buf[100]; + char filter_buf[100]; + char fflags_buf[1000]; + char flags_buf[1000] = "0x0"; + char *flags_off = NULL; + char *fflags_off = NULL; + unsigned short flags = kev->flags; + unsigned int fflags = kev->fflags; + + if (flags) while (flags) { + if (flags_off) { + *flags_off = '|'; + flags_off++; + *flags_off = '\0'; + } else { + flags_off = flags_buf; + } + if (flags & EV_ADD) { + flags_off += sprintf(flags_off, "EV_ADD"); + flags &= ~EV_ADD; + } else if (flags & EV_DELETE) { + flags_off += sprintf(flags_off, "EV_DELETE"); + flags &= ~EV_DELETE; + } else if (flags & EV_ENABLE) { + flags_off += sprintf(flags_off, "EV_ENABLE"); + flags &= ~EV_ENABLE; + } else if (flags & EV_DISABLE) { + flags_off += sprintf(flags_off, "EV_DISABLE"); + flags &= ~EV_DISABLE; + } else if (flags & EV_ONESHOT) { + flags_off += sprintf(flags_off, "EV_ONESHOT"); + flags &= ~EV_ONESHOT; + } else if (flags & EV_CLEAR) { + flags_off += sprintf(flags_off, "EV_CLEAR"); + flags &= ~EV_CLEAR; + } else if (flags & EV_EOF) { + flags_off += sprintf(flags_off, "EV_EOF"); + flags &= ~EV_EOF; + } else if (flags & EV_ERROR) { + flags_off += sprintf(flags_off, "EV_ERROR"); + flags &= ~EV_ERROR; + } else { + flags_off += sprintf(flags_off, "0x%x", flags); + flags = 0; + } + } + + snprintf(ident_buf, sizeof(ident_buf), "%ld", kev->ident); + snprintf(fflags_buf, sizeof(fflags_buf), "0x%x", fflags); + + switch (kev->filter) { + case EVFILT_READ: + filter_str = "EVFILT_READ"; + break; + case EVFILT_WRITE: + filter_str = "EVFILT_WRITE"; + break; + case EVFILT_AIO: + filter_str = "EVFILT_AIO"; + break; + case EVFILT_VNODE: + filter_str = "EVFILT_VNODE"; + if (fflags) while (fflags) { + if (fflags_off) { + *fflags_off = '|'; + fflags_off++; + *fflags_off = '\0'; + } else { + fflags_off = fflags_buf; + } + +#define FFLAGIF(ff) if (fflags & ff) { fflags_off += sprintf(fflags_off, #ff); fflags &= ~ff; } + + FFLAGIF(NOTE_DELETE) + else FFLAGIF(NOTE_WRITE) + else FFLAGIF(NOTE_EXTEND) + else FFLAGIF(NOTE_ATTRIB) + else FFLAGIF(NOTE_LINK) + else FFLAGIF(NOTE_RENAME) + else FFLAGIF(NOTE_REVOKE) + else { + fflags_off += sprintf(fflags_off, "0x%x", fflags); + fflags = 0; + } + } + break; + case EVFILT_PROC: + filter_str = "EVFILT_PROC"; + if (fflags) while (fflags) { + if (fflags_off) { + *fflags_off = '|'; + fflags_off++; + *fflags_off = '\0'; + } else { + fflags_off = fflags_buf; + } + + FFLAGIF(NOTE_EXIT) + else FFLAGIF(NOTE_FORK) + else FFLAGIF(NOTE_EXEC) + else FFLAGIF(NOTE_TRACK) + else FFLAGIF(NOTE_TRACKERR) + else FFLAGIF(NOTE_CHILD) + else { + fflags_off += sprintf(fflags_off, "0x%x", fflags); + fflags = 0; + } + } + break; + case EVFILT_SIGNAL: + filter_str = "EVFILT_SIGNAL"; + switch (kev->ident) { +#define SIG2CASE(sg) case sg: sprintf(ident_buf, #sg); break + SIG2CASE(SIGHUP); + SIG2CASE(SIGINT); + SIG2CASE(SIGQUIT); + SIG2CASE(SIGILL); + SIG2CASE(SIGTRAP); + SIG2CASE(SIGABRT); + SIG2CASE(SIGFPE); + SIG2CASE(SIGKILL); + SIG2CASE(SIGBUS); + SIG2CASE(SIGSEGV); + SIG2CASE(SIGSYS); + SIG2CASE(SIGPIPE); + SIG2CASE(SIGALRM); + SIG2CASE(SIGTERM); + SIG2CASE(SIGURG); + SIG2CASE(SIGSTOP); + SIG2CASE(SIGTSTP); + SIG2CASE(SIGCONT); + SIG2CASE(SIGCHLD); + SIG2CASE(SIGTTIN); + SIG2CASE(SIGTTOU); + SIG2CASE(SIGIO); + SIG2CASE(SIGXCPU); + SIG2CASE(SIGXFSZ); + SIG2CASE(SIGVTALRM); + SIG2CASE(SIGPROF); + SIG2CASE(SIGWINCH); + SIG2CASE(SIGINFO); + SIG2CASE(SIGUSR1); + SIG2CASE(SIGUSR2); + default: + sprintf(ident_buf, "%ld", kev->ident); + break; + } + break; + case EVFILT_TIMER: + filter_str = "EVFILT_TIMER"; + snprintf(ident_buf, sizeof(ident_buf), "0x%lx", kev->ident); + if (fflags) while (fflags) { + if (fflags_off) { + *fflags_off = '|'; + fflags_off++; + *fflags_off = '\0'; + } else { + fflags_off = fflags_buf; + } + + FFLAGIF(NOTE_SECONDS) + else FFLAGIF(NOTE_USECONDS) + else FFLAGIF(NOTE_NSECONDS) + else FFLAGIF(NOTE_ABSOLUTE) + else { + fflags_off += sprintf(fflags_off, "0x%x", fflags); + fflags = 0; + } + } + break; + case EVFILT_MACHPORT: + filter_str = "EVFILT_MACHPORT"; + snprintf(ident_buf, sizeof(ident_buf), "0x%lx", kev->ident); + break; + case EVFILT_FS: + filter_str = "EVFILT_FS"; + break; + default: + snprintf(filter_buf, sizeof(filter_buf), "%d", kev->filter); + filter_str = filter_buf; + break; + } + + syslog(level, "KEVENT: ident = %s filter = %s flags = %s fflags = %s data = 0x%x udata = %p", + ident_buf, filter_str, flags_buf, fflags_buf, kev->data, kev->udata); +} + kern_return_t x_handle_mport(mach_port_t junk __attribute__((unused))) { @@ -166,7 +357,10 @@ if (status.mps_msgcount) { EV_SET(&kev, members[i], EVFILT_MACHPORT, 0, 0, 0, jobmgr_find_by_service_port(root_jobmgr, members[i])); if (launchd_assumes(kev.udata != NULL)) { + log_kevent_struct(LOG_DEBUG, &kev); (*((kq_callback *)kev.udata))(kev.udata, &kev); + } else { + log_kevent_struct(LOG_ERR, &kev); } /* the callback may have tainted our ability to continue this for loop */ break; @@ -207,10 +401,10 @@ if (kevr == 1) { if (launchd_assumes(malloc_size(kev.udata) || dladdr(kev.udata, &dli))) { + log_kevent_struct(LOG_DEBUG, &kev); (*((kq_callback *)kev.udata))(kev.udata, &kev); } else { - syslog(LOG_ERR, "kev.ident == 0x%x kev.filter == 0x%x kev.fflags = 0x%x kev.udata = 0x%x", - kev.ident, kev.filter, kev.fflags, kev.udata); + log_kevent_struct(LOG_ERR, &kev); } } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070214/1caff8a8/attachment.html From source_changes at macosforge.org Wed Feb 14 11:51:28 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:40 2007 Subject: [launchd-changes] [23063] trunk/launchd/src/launchd_runtime.c Message-ID: <20070214195128.0DAE74A6A5D@cvs.opensource.apple.com> Revision: 23063 http://trac.macosforge.org/projects/launchd/changeset/23063 Author: zarzycki@apple.com Date: 2007-02-14 11:51:27 -0800 (Wed, 14 Feb 2007) Log Message: ----------- Macros for fun and profit. Modified Paths: -------------- trunk/launchd/src/launchd_runtime.c Modified: trunk/launchd/src/launchd_runtime.c =================================================================== --- trunk/launchd/src/launchd_runtime.c 2007-02-14 19:41:31 UTC (rev 23062) +++ trunk/launchd/src/launchd_runtime.c 2007-02-14 19:51:27 UTC (rev 23063) @@ -164,31 +164,18 @@ } else { flags_off = flags_buf; } - if (flags & EV_ADD) { - flags_off += sprintf(flags_off, "EV_ADD"); - flags &= ~EV_ADD; - } else if (flags & EV_DELETE) { - flags_off += sprintf(flags_off, "EV_DELETE"); - flags &= ~EV_DELETE; - } else if (flags & EV_ENABLE) { - flags_off += sprintf(flags_off, "EV_ENABLE"); - flags &= ~EV_ENABLE; - } else if (flags & EV_DISABLE) { - flags_off += sprintf(flags_off, "EV_DISABLE"); - flags &= ~EV_DISABLE; - } else if (flags & EV_ONESHOT) { - flags_off += sprintf(flags_off, "EV_ONESHOT"); - flags &= ~EV_ONESHOT; - } else if (flags & EV_CLEAR) { - flags_off += sprintf(flags_off, "EV_CLEAR"); - flags &= ~EV_CLEAR; - } else if (flags & EV_EOF) { - flags_off += sprintf(flags_off, "EV_EOF"); - flags &= ~EV_EOF; - } else if (flags & EV_ERROR) { - flags_off += sprintf(flags_off, "EV_ERROR"); - flags &= ~EV_ERROR; - } else { + +#define FLAGIF(f) if (flags & f) { flags_off += sprintf(flags_off, #f); flags &= ~f; } + + FLAGIF(EV_ADD) + else FLAGIF(EV_DELETE) + else FLAGIF(EV_ENABLE) + else FLAGIF(EV_DISABLE) + else FLAGIF(EV_ONESHOT) + else FLAGIF(EV_CLEAR) + else FLAGIF(EV_EOF) + else FLAGIF(EV_ERROR) + else { flags_off += sprintf(flags_off, "0x%x", flags); flags = 0; } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070214/8c7649aa/attachment.html From source_changes at macosforge.org Wed Feb 14 12:01:09 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:40 2007 Subject: [launchd-changes] [23064] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070214200109.572DE4A6AA5@cvs.opensource.apple.com> Revision: 23064 http://trac.macosforge.org/projects/launchd/changeset/23064 Author: zarzycki@apple.com Date: 2007-02-14 12:01:09 -0800 (Wed, 14 Feb 2007) Log Message: ----------- 9A357: hang on startup after install to case sensitive volume Modified Paths: -------------- trunk/launchd/src/launchd_core_logic.c Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2007-02-14 19:51:27 UTC (rev 23063) +++ trunk/launchd/src/launchd_core_logic.c 2007-02-14 20:01:09 UTC (rev 23064) @@ -1963,9 +1963,7 @@ job_log_error(j, LOG_ERR, "kevent()"); job_reap(j); } else { - if (j->ondemand) { - job_ignore(j); - } + job_ignore(j); } if (!j->stall_before_exec) { -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070214/ca86b314/attachment.html From source_changes at macosforge.org Wed Feb 14 12:14:38 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:40 2007 Subject: [launchd-changes] [23065] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070214201438.96B5A4A6AD1@cvs.opensource.apple.com> Revision: 23065 http://trac.macosforge.org/projects/launchd/changeset/23065 Author: zarzycki@apple.com Date: 2007-02-14 12:14:38 -0800 (Wed, 14 Feb 2007) Log Message: ----------- We're not ready to do anything useful with NOTE_EXEC or NOTE_FORK yet. We may never do anything with NOTE_FORK for that matter. Modified Paths: -------------- trunk/launchd/src/launchd_core_logic.c Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2007-02-14 20:01:09 UTC (rev 23064) +++ trunk/launchd/src/launchd_core_logic.c 2007-02-14 20:14:38 UTC (rev 23065) @@ -1802,6 +1802,10 @@ job_log(j, LOG_DEBUG, "Called execve()"); } + if (fflags & NOTE_FORK) { + job_log(j, LOG_DEBUG, "Called fork()"); + } + if (fflags & NOTE_EXIT) { job_reap(j); job_dispatch(j, false); @@ -1959,7 +1963,7 @@ job_assumes(j, close(spair[1]) == 0); ipc_open(_fd(spair[0]), j); } - if (kevent_mod(c, EVFILT_PROC, EV_ADD, NOTE_EXEC|NOTE_EXIT, 0, &j->kqjob_callback) == -1) { + if (kevent_mod(c, EVFILT_PROC, EV_ADD, /* NOTE_EXEC|NOTE_FORK| */ NOTE_EXIT, 0, &j->kqjob_callback) == -1) { job_log_error(j, LOG_ERR, "kevent()"); job_reap(j); } else { -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070214/d737709e/attachment.html From source_changes at macosforge.org Wed Feb 14 13:45:02 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:40 2007 Subject: [launchd-changes] [23066] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070214214502.9A4F14A6BFC@cvs.opensource.apple.com> Revision: 23066 http://trac.macosforge.org/projects/launchd/changeset/23066 Author: zarzycki@apple.com Date: 2007-02-14 13:45:02 -0800 (Wed, 14 Feb 2007) Log Message: ----------- Compile time assert tricks are cool. Modified Paths: -------------- trunk/launchd/src/launchd_core_logic.c Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2007-02-14 20:14:38 UTC (rev 23065) +++ trunk/launchd/src/launchd_core_logic.c 2007-02-14 21:45:02 UTC (rev 23066) @@ -919,6 +919,7 @@ job_t job_new(jobmgr_t jm, const char *label, const char *prog, const char *const *argv, const char *stdinpath) { + char compile_time_assert[offsetof(struct job_s, kqjob_callback) == 0 ? 1 : -1] __attribute__((unused)); const char *const *argv_tmp = argv; char *co; int i, cc = 0; @@ -1963,7 +1964,7 @@ job_assumes(j, close(spair[1]) == 0); ipc_open(_fd(spair[0]), j); } - if (kevent_mod(c, EVFILT_PROC, EV_ADD, /* NOTE_EXEC|NOTE_FORK| */ NOTE_EXIT, 0, &j->kqjob_callback) == -1) { + if (kevent_mod(c, EVFILT_PROC, EV_ADD, /* NOTE_EXEC|NOTE_FORK| */ NOTE_EXIT, 0, j) == -1) { job_log_error(j, LOG_ERR, "kevent()"); job_reap(j); } else { -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070214/ca66cd8d/attachment.html From source_changes at macosforge.org Wed Feb 14 13:45:13 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:40 2007 Subject: [launchd-changes] [23067] tags/launchd-195/ Message-ID: <20070214214513.627A94A6C00@cvs.opensource.apple.com> Revision: 23067 http://trac.macosforge.org/projects/launchd/changeset/23067 Author: zarzycki@apple.com Date: 2007-02-14 13:45:13 -0800 (Wed, 14 Feb 2007) Log Message: ----------- "Tagging launchd-195 from https://svn.macosforge.org/repository/launchd/trunk" Added Paths: ----------- tags/launchd-195/ Copied: tags/launchd-195 (from rev 23066, trunk) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070214/32311131/attachment.html From source_changes at macosforge.org Thu Feb 15 08:12:24 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:40 2007 Subject: [launchd-changes] [23068] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070215161224.E49E94A72AC@cvs.opensource.apple.com> Revision: 23068 http://trac.macosforge.org/projects/launchd/changeset/23068 Author: zarzycki@apple.com Date: 2007-02-15 08:12:24 -0800 (Thu, 15 Feb 2007) Log Message: ----------- launchd restarting on-demand service twice Modified Paths: -------------- trunk/launchd/src/launchd_core_logic.c Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2007-02-14 21:45:13 UTC (rev 23067) +++ trunk/launchd/src/launchd_core_logic.c 2007-02-15 16:12:24 UTC (rev 23068) @@ -687,9 +687,6 @@ if (j->start_interval) { job_assumes(j, kevent_mod((uintptr_t)&j->start_interval, EVFILT_TIMER, EV_DELETE, 0, 0, NULL) != -1); } - if (j->exit_timeout) { - kevent_mod((uintptr_t)&j->exit_timeout, EVFILT_TIMER, EV_DELETE, 0, 0, NULL); - } kevent_mod((uintptr_t)j, EVFILT_TIMER, EV_DELETE, 0, 0, NULL); @@ -1654,6 +1651,10 @@ return; } + if (j->exit_timeout) { + kevent_mod((uintptr_t)&j->exit_timeout, EVFILT_TIMER, EV_DELETE, 0, 0, NULL); + } + total_children--; /* Performance hack */ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070215/25b74351/attachment.html From source_changes at macosforge.org Thu Feb 15 08:12:49 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:40 2007 Subject: [launchd-changes] [23069] trunk/launchd/src Message-ID: <20070215161249.344BB4A72B8@cvs.opensource.apple.com> Revision: 23069 http://trac.macosforge.org/projects/launchd/changeset/23069 Author: zarzycki@apple.com Date: 2007-02-15 08:12:48 -0800 (Thu, 15 Feb 2007) Log Message: ----------- Documentation update. Modified Paths: -------------- trunk/launchd/src/launchd.plist.5 trunk/launchd/src/launchd_core_logic.c Modified: trunk/launchd/src/launchd.plist.5 =================================================================== --- trunk/launchd/src/launchd.plist.5 2007-02-15 16:12:24 UTC (rev 23068) +++ trunk/launchd/src/launchd.plist.5 2007-02-15 16:12:48 UTC (rev 23069) @@ -232,7 +232,7 @@ .It Sy WaitForDebugger This optional key specifies that .Nm launchd -should instruct the kernel to have the job wait for a debugger to attach before any code in the job is executed. +should instruct the kernel to have the job wait for a debugger to attach before any code in the job is executed. This feature may not work due to bug 4438161. .It Sy SoftResourceLimits .It Sy HardResourceLimits Resource limits to be imposed on the job. These adjust variables set with Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2007-02-15 16:12:24 UTC (rev 23068) +++ trunk/launchd/src/launchd_core_logic.c 2007-02-15 16:12:48 UTC (rev 23069) @@ -2027,6 +2027,7 @@ } if (j->wait4debugger) { + /* 4438161 gdb hangs when trying to attach to SIGSTOPed processes (breaks launchd's "WaitForDebugger") */ spflags |= POSIX_SPAWN_START_SUSPENDED; } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070215/50317b1c/attachment.html From source_changes at macosforge.org Thu Feb 15 10:26:23 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:40 2007 Subject: [launchd-changes] [23070] trunk/launchd/src Message-ID: <20070215182623.143884A73B5@cvs.opensource.apple.com> Revision: 23070 http://trac.macosforge.org/projects/launchd/changeset/23070 Author: zarzycki@apple.com Date: 2007-02-15 10:26:22 -0800 (Thu, 15 Feb 2007) Log Message: ----------- poweroff() API to wrap reboot() Modified Paths: -------------- trunk/launchd/src/Makefile.am trunk/launchd/src/Makefile.in trunk/launchd/src/launchd_core_logic.c trunk/launchd/src/libvproc.c trunk/launchd/src/protocol_job.defs Added Paths: ----------- trunk/launchd/src/poweroff.h Modified: trunk/launchd/src/Makefile.am =================================================================== --- trunk/launchd/src/Makefile.am 2007-02-15 16:12:48 UTC (rev 23069) +++ trunk/launchd/src/Makefile.am 2007-02-15 18:26:22 UTC (rev 23070) @@ -89,6 +89,7 @@ mkdir -p $(DESTDIR)/usr/local/include cp $(srcdir)/liblaunch_private.h $(DESTDIR)/usr/local/include/launch_priv.h cp $(srcdir)/libvproc_private.h $(DESTDIR)/usr/local/include/vproc_priv.h + cp $(srcdir)/poweroff.h $(DESTDIR)/usr/local/include/poweroff.h mkdir -p $(DESTDIR)/$(sysconfdir)/mach_init.d mkdir -p $(DESTDIR)/$(sysconfdir)/mach_init_per_user.d mkdir -p $(DESTDIR)/Library/LaunchDaemons Modified: trunk/launchd/src/Makefile.in =================================================================== --- trunk/launchd/src/Makefile.in 2007-02-15 16:12:48 UTC (rev 23069) +++ trunk/launchd/src/Makefile.in 2007-02-15 18:26:22 UTC (rev 23070) @@ -1103,6 +1103,7 @@ @LIBS_ONLY_FALSE@ mkdir -p $(DESTDIR)/usr/local/include @LIBS_ONLY_FALSE@ cp $(srcdir)/liblaunch_private.h $(DESTDIR)/usr/local/include/launch_priv.h @LIBS_ONLY_FALSE@ cp $(srcdir)/libvproc_private.h $(DESTDIR)/usr/local/include/vproc_priv.h +@LIBS_ONLY_FALSE@ cp $(srcdir)/poweroff.h $(DESTDIR)/usr/local/include/poweroff.h @LIBS_ONLY_FALSE@ mkdir -p $(DESTDIR)/$(sysconfdir)/mach_init.d @LIBS_ONLY_FALSE@ mkdir -p $(DESTDIR)/$(sysconfdir)/mach_init_per_user.d @LIBS_ONLY_FALSE@ mkdir -p $(DESTDIR)/Library/LaunchDaemons Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2007-02-15 16:12:48 UTC (rev 23069) +++ trunk/launchd/src/launchd_core_logic.c 2007-02-15 18:26:22 UTC (rev 23070) @@ -80,6 +80,8 @@ #include "libvproc_public.h" #include "libvproc_internal.h" +