From source_changes at macosforge.org Tue Sep 4 14:18:31 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:52 2007 Subject: [launchd-changes] [23350] trunk/launchd/src/launchd.plist.5 Message-ID: <20070904211831.72F08777B04@cvs.opensource.apple.com> Revision: 23350 http://trac.macosforge.org/projects/launchd/changeset/23350 Author: zarzycki@apple.com Date: 2007-09-04 14:18:30 -0700 (Tue, 04 Sep 2007) Log Message: ----------- DOC: launchd.plist man page is out of date Modified Paths: -------------- trunk/launchd/src/launchd.plist.5 Modified: trunk/launchd/src/launchd.plist.5 =================================================================== --- trunk/launchd/src/launchd.plist.5 2007-08-24 22:17:58 UTC (rev 23349) +++ trunk/launchd/src/launchd.plist.5 2007-09-04 21:18:30 UTC (rev 23350) @@ -239,7 +239,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. This feature may not work due to bug 4438161. +should instruct the kernel to have the job wait for a debugger to attach before any code in the job is executed. .It Sy SoftResourceLimits .It Sy HardResourceLimits Resource limits to be imposed on the job. These adjust variables set with -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070904/05b19fff/attachment.html From source_changes at macosforge.org Tue Sep 4 14:19:55 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:52 2007 Subject: [launchd-changes] [23351] trunk/launchd/src/launchctl.1 Message-ID: <20070904211955.9BA2F777B90@cvs.opensource.apple.com> Revision: 23351 http://trac.macosforge.org/projects/launchd/changeset/23351 Author: zarzycki@apple.com Date: 2007-09-04 14:19:55 -0700 (Tue, 04 Sep 2007) Log Message: ----------- DOC: typo in the launchctl(1) man page Modified Paths: -------------- trunk/launchd/src/launchctl.1 Modified: trunk/launchd/src/launchctl.1 =================================================================== --- trunk/launchd/src/launchctl.1 2007-09-04 21:18:30 UTC (rev 23350) +++ trunk/launchd/src/launchctl.1 2007-09-04 21:19:55 UTC (rev 23351) @@ -143,7 +143,7 @@ This prints out Mach bootstrap services and their respective states. While the namespace appears flat, it is in fact hierarchical, thus allowing for certain services to be only available to a subset of processes. The three states a -service can be in are active ("A"), in-active ("I") and on-demand ("D"). +service can be in are active ("A"), inactive ("I") and on-demand ("D"). .It Ar bsexec Ar PID command Op Ar args This executes the given command in the same Mach bootstrap namespace hierachy as the given PID. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070904/735db24c/attachment.html From source_changes at macosforge.org Tue Sep 4 14:23:22 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:52 2007 Subject: [launchd-changes] [23352] trunk/launchd/src/launchctl.1 Message-ID: <20070904212322.B63A0777C08@cvs.opensource.apple.com> Revision: 23352 http://trac.macosforge.org/projects/launchd/changeset/23352 Author: zarzycki@apple.com Date: 2007-09-04 14:23:22 -0700 (Tue, 04 Sep 2007) Log Message: ----------- launchctl documention doesn't list -S argument to unload Modified Paths: -------------- trunk/launchd/src/launchctl.1 Modified: trunk/launchd/src/launchctl.1 =================================================================== --- trunk/launchd/src/launchctl.1 2007-09-04 21:19:55 UTC (rev 23351) +++ trunk/launchd/src/launchctl.1 2007-09-04 21:23:22 UTC (rev 23352) @@ -53,6 +53,8 @@ With a session type passed, it would load from /System/Library/LaunchAgents. .El .It Xo Ar unload Op Fl w +.Op Fl S Ar sessiontype +.Op Fl D Ar domain .Ar paths ... .Xc Unload the specified configuration files or directories of configuration files. @@ -60,6 +62,20 @@ .Bl -tag -width -indent .It Fl w Add the disabled key and write the configuration files back out to disk. +.It Fl S Ar sessiontype +Some jobs only make sense in certain contexts. This flag instructs +.Nm launchctl +to look for jobs in a different location when using the -D flag, and allows +.Nm launchctl +to restrict which jobs are loaded into which session types. Currently known +session types include: Aqua, LoginWindow, Background, StandardIO and System. +.It Fl D Ar domain +Look for +.Xr plist 5 files ending in *.plist in the domain given. Valid domains include +"system," "local," "network" and "all." When providing a session type, an additional +domain is available for use called "user." For example, without a session type given, +"-D system" would load from property list files from /System/Library/LaunchDaemons. +With a session type passed, it would load from /System/Library/LaunchAgents. .El .It Xo Ar submit Fl l Ar label .Op Fl p Ar executable -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070904/259e6bf2/attachment.html From source_changes at macosforge.org Tue Sep 4 15:55:10 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:52 2007 Subject: [launchd-changes] [23353] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070904225510.CE808778BE3@cvs.opensource.apple.com> Revision: 23353 http://trac.macosforge.org/projects/launchd/changeset/23353 Author: zarzycki@apple.com Date: 2007-09-04 15:55:10 -0700 (Tue, 04 Sep 2007) Log Message: ----------- 9A536: No SMB sharing 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-09-04 21:23:22 UTC (rev 23352) +++ trunk/launchd/src/launchd_core_logic.c 2007-09-04 22:55:10 UTC (rev 23353) @@ -2033,6 +2033,16 @@ job_start(j); } else { job_watch(j); + + /* + * 5455720 + * + * Path checking and monitoring is really racy right now. + * We should clean this up post Leopard. + */ + if (job_keepalive(j)) { + job_start(j); + } } } else { job_log(j, LOG_DEBUG, "Tried to dispatch an already active job."); -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070904/e696c146/attachment.html From source_changes at macosforge.org Tue Sep 4 16:33:26 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:52 2007 Subject: [launchd-changes] [23354] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070904233326.1C30477913F@cvs.opensource.apple.com> Revision: 23354 http://trac.macosforge.org/projects/launchd/changeset/23354 Author: zarzycki@apple.com Date: 2007-09-04 16:33:25 -0700 (Tue, 04 Sep 2007) Log Message: ----------- Investigating: Logged out after waking from sleep 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-09-04 22:55:10 UTC (rev 23353) +++ trunk/launchd/src/launchd_core_logic.c 2007-09-04 23:33:25 UTC (rev 23354) @@ -2596,8 +2596,11 @@ job_log(j, LOG_ERR, "PID %u \"%s\" has no account to back it! Real/effective/saved UIDs: %u/%u/%u", i_pid, kp[i].kp_proc.p_comm, i_uid, i_euid, i_svuid); +/* Temporarily disabled due to 5423935 and 4946119. */ +#if 0 /* Ask the accountless process to exit. */ job_assumes(j, kill(i_pid, SIGTERM) != -1); +#endif } out: -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070904/4a61cfab/attachment.html From source_changes at macosforge.org Wed Sep 5 08:04:36 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:52 2007 Subject: [launchd-changes] [23355] trunk/launchd/src/StartupItems.c Message-ID: <20070905150436.B495E77E9CE@cvs.opensource.apple.com> Revision: 23355 http://trac.macosforge.org/projects/launchd/changeset/23355 Author: zarzycki@apple.com Date: 2007-09-05 08:04:36 -0700 (Wed, 05 Sep 2007) Log Message: ----------- Mac Pro SMC firmware update 1.1 does not begin after restart Modified Paths: -------------- trunk/launchd/src/StartupItems.c Modified: trunk/launchd/src/StartupItems.c =================================================================== --- trunk/launchd/src/StartupItems.c 2007-09-04 23:33:25 UTC (rev 23354) +++ trunk/launchd/src/StartupItems.c 2007-09-05 15:04:36 UTC (rev 23355) @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -217,15 +218,31 @@ static bool StartupItemSecurityCheck(const char *aPath) { + static struct timeval boot_time; struct stat aStatBuf; bool r = true; + if (boot_time.tv_sec == 0) { + int mib[] = { CTL_KERN, KERN_BOOTTIME }; + size_t boot_time_sz = sizeof(boot_time); + int rv; + + rv = sysctl(mib, sizeof(mib) / sizeof(mib[0]), &boot_time, &boot_time_sz, NULL, 0); + + assert(rv != -1); + assert(boot_time_sz == sizeof(boot_time)); + } + /* should use lstatx_np() on Tiger? */ if (lstat(aPath, &aStatBuf) == -1) { if (errno != ENOENT) syslog(LOG_ERR, "lstat(\"%s\"): %m", aPath); return false; } + if (aStatBuf.st_ctimespec.tv_sec > boot_time.tv_sec) { + syslog(LOG_WARNING, "\"%s\" failed sanity check: path was created after boot up", aPath); + return false; + } if (!(S_ISREG(aStatBuf.st_mode) || S_ISDIR(aStatBuf.st_mode))) { syslog(LOG_WARNING, "\"%s\" failed security check: not a directory or regular file", aPath); r = false; -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070905/9127020b/attachment.html From source_changes at macosforge.org Wed Sep 5 11:20:21 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:52 2007 Subject: [launchd-changes] [23356] trunk/launchd/src Message-ID: <20070905182021.9D69377EF6B@cvs.opensource.apple.com> Revision: 23356 http://trac.macosforge.org/projects/launchd/changeset/23356 Author: zarzycki@apple.com Date: 2007-09-05 11:20:21 -0700 (Wed, 05 Sep 2007) Log Message: ----------- signal handling bugs found during code audit SIGTERM might be ignored for a tiny window post fork() and pre execve() in the child. SIGTERM might be ignored for a tiny window of launchd's initialization of itself. Modified Paths: -------------- trunk/launchd/src/launchd.c trunk/launchd/src/launchd_core_logic.c trunk/launchd/src/launchd_runtime.c trunk/launchd/src/launchd_runtime.h Modified: trunk/launchd/src/launchd.c =================================================================== --- trunk/launchd/src/launchd.c 2007-09-05 15:04:36 UTC (rev 23355) +++ trunk/launchd/src/launchd.c 2007-09-05 18:20:21 UTC (rev 23356) @@ -106,13 +106,7 @@ int main(int argc, char *const *argv) { - static const int sigigns[] = { SIGHUP, SIGINT, SIGPIPE, SIGALRM, - SIGTERM, SIGURG, SIGTSTP, SIGTSTP, SIGCONT, SIGTTIN, - SIGTTOU, SIGIO, SIGXCPU, SIGXFSZ, SIGVTALRM, SIGPROF, - SIGWINCH, SIGINFO, SIGUSR1, SIGUSR2 - }; bool sflag = false; - size_t i; int ch; testfd_or_openfd(STDIN_FILENO, _PATH_DEVNULL, O_RDONLY); @@ -136,10 +130,6 @@ launchd_runtime_init(); - for (i = 0; i < (sizeof(sigigns) / sizeof(int)); i++) { - launchd_assumes(signal(sigigns[i], SIG_IGN) != SIG_ERR); - } - if (NULL == getenv("PATH")) { setenv("PATH", _PATH_STDPATH, 1); } @@ -152,13 +142,14 @@ monitor_networking_state(); - if (getpid() == 1) { handle_pid1_crashes_separately(); } jobmgr_init(sflag); + launchd_runtime_init2(); + launchd_runtime(); } Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2007-09-05 15:04:36 UTC (rev 23355) +++ trunk/launchd/src/launchd_core_logic.c 2007-09-05 18:20:21 UTC (rev 23356) @@ -2482,10 +2482,6 @@ job_assumes(j, binpref_out_cnt == j->j_binpref_cnt); } - for (i = 1; i < NSIG; i++) { - signal(i, SIG_DFL); - } - if (j->quarantine_data) { qtn_proc_t qp; Modified: trunk/launchd/src/launchd_runtime.c =================================================================== --- trunk/launchd/src/launchd_runtime.c 2007-09-05 15:04:36 UTC (rev 23355) +++ trunk/launchd/src/launchd_runtime.c 2007-09-05 18:20:21 UTC (rev 23356) @@ -54,6 +54,7 @@ #include #include #include +#include #include #include "launchd_internalServer.h" @@ -105,6 +106,13 @@ static bool logmsg_add(struct runtime_syslog_attr *attr, int err_num, const char *msg); static void logmsg_remove(struct logmsg_s *lm); + +static const int sigigns[] = { SIGHUP, SIGINT, SIGPIPE, SIGALRM, SIGTERM, + SIGURG, SIGTSTP, SIGTSTP, SIGCONT, SIGTTIN, SIGTTOU, SIGIO, SIGXCPU, + SIGXFSZ, SIGVTALRM, SIGPROF, SIGWINCH, SIGINFO, SIGUSR1, SIGUSR2 +}; +static sigset_t sigign_set; + void launchd_runtime_init(void) { @@ -143,6 +151,17 @@ runtime_setlogmask(LOG_UPTO(/* LOG_DEBUG */ LOG_NOTICE)); } +void +launchd_runtime_init2(void) +{ + size_t i; + + for (i = 0; i < (sizeof(sigigns) / sizeof(int)); i++) { + sigaddset(&sigign_set, sigigns[i]); + launchd_assumes(signal(sigigns[i], SIG_IGN) != SIG_ERR); + } +} + void * mport_demand_loop(void *arg __attribute__((unused))) { @@ -583,19 +602,33 @@ pid_t runtime_fork(mach_port_t bsport) { + sigset_t emptyset, oset; pid_t r = -1; int saved_errno; + size_t i; + sigemptyset(&emptyset); + launchd_assumes(launchd_mport_make_send(bsport) == KERN_SUCCESS); launchd_assumes(launchd_set_bport(bsport) == KERN_SUCCESS); launchd_assumes(launchd_mport_deallocate(bsport) == KERN_SUCCESS); + launchd_assumes(sigprocmask(SIG_BLOCK, &sigign_set, &oset) != -1); + for (i = 0; i < (sizeof(sigigns) / sizeof(int)); i++) { + launchd_assumes(signal(sigigns[i], SIG_DFL) != SIG_ERR); + } + r = fork(); - saved_errno = errno; if (r != 0) { + for (i = 0; i < (sizeof(sigigns) / sizeof(int)); i++) { + launchd_assumes(signal(sigigns[i], SIG_IGN) != SIG_ERR); + } + launchd_assumes(sigprocmask(SIG_SETMASK, &oset, NULL) != -1); launchd_assumes(launchd_set_bport(MACH_PORT_NULL) == KERN_SUCCESS); + } else { + launchd_assumes(sigprocmask(SIG_SETMASK, &emptyset, NULL) != -1); } errno = saved_errno; Modified: trunk/launchd/src/launchd_runtime.h =================================================================== --- trunk/launchd/src/launchd_runtime.h 2007-09-05 15:04:36 UTC (rev 23355) +++ trunk/launchd/src/launchd_runtime.h 2007-09-05 18:20:21 UTC (rev 23356) @@ -57,6 +57,7 @@ boolean_t launchd_internal_demux(mach_msg_header_t *Request, mach_msg_header_t *Reply); void launchd_runtime_init(void); +void launchd_runtime_init2(void); void launchd_runtime(void) __attribute__((noreturn)); int runtime_close(int fd); -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070905/dff6905e/attachment.html From source_changes at macosforge.org Wed Sep 5 13:33:15 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:52 2007 Subject: [launchd-changes] [23357] trunk/launchd/src/launchd_runtime.c Message-ID: <20070905203315.70D6777F214@cvs.opensource.apple.com> Revision: 23357 http://trac.macosforge.org/projects/launchd/changeset/23357 Author: zarzycki@apple.com Date: 2007-09-05 13:33:15 -0700 (Wed, 05 Sep 2007) Log Message: ----------- Some help for debugging reboot hangs. Modified Paths: -------------- trunk/launchd/src/launchd_runtime.c Modified: trunk/launchd/src/launchd_runtime.c =================================================================== --- trunk/launchd/src/launchd_runtime.c 2007-09-05 18:20:21 UTC (rev 23356) +++ trunk/launchd/src/launchd_runtime.c 2007-09-05 20:33:15 UTC (rev 23357) @@ -1037,6 +1037,10 @@ { if (ourlogfile) { fflush(ourlogfile); + + if (debug_shutdown_hangs) { + fcntl(fileno(ourlogfile), F_FULLFSYNC, NULL); + } } } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070905/9814cd19/attachment.html From source_changes at macosforge.org Wed Sep 5 14:14:10 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:52 2007 Subject: [launchd-changes] [23358] tags/launchd-241/ Message-ID: <20070905211410.29BCB77F326@cvs.opensource.apple.com> Revision: 23358 http://trac.macosforge.org/projects/launchd/changeset/23358 Author: zarzycki@apple.com Date: 2007-09-05 14:14:09 -0700 (Wed, 05 Sep 2007) Log Message: ----------- "Tagging launchd-241 from https://svn.macosforge.org/repository/launchd/trunk" Added Paths: ----------- tags/launchd-241/ Copied: tags/launchd-241 (from rev 23357, trunk) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070905/d6b9cb9b/attachment.html From source_changes at macosforge.org Thu Sep 6 15:24:34 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:52 2007 Subject: [launchd-changes] [23359] trunk/launchd/src Message-ID: <20070906222434.A64DE78A9DB@cvs.opensource.apple.com> Revision: 23359 http://trac.macosforge.org/projects/launchd/changeset/23359 Author: zarzycki@apple.com Date: 2007-09-06 15:24:34 -0700 (Thu, 06 Sep 2007) Log Message: ----------- Create a wrapper around fsync(). Modified Paths: -------------- trunk/launchd/src/launchd_core_logic.c trunk/launchd/src/launchd_runtime.c trunk/launchd/src/launchd_runtime.h Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2007-09-05 21:14:09 UTC (rev 23358) +++ trunk/launchd/src/launchd_core_logic.c 2007-09-06 22:24:34 UTC (rev 23359) @@ -4492,7 +4492,7 @@ } if (logfile_fd != -1) { - job_assumes(j, fcntl(logfile_fd, F_FULLFSYNC, 0) != -1); + job_assumes(j, runtime_fsync(logfile_fd) != -1); job_assumes(j, runtime_close(logfile_fd) != -1); } Modified: trunk/launchd/src/launchd_runtime.c =================================================================== --- trunk/launchd/src/launchd_runtime.c 2007-09-05 21:14:09 UTC (rev 23358) +++ trunk/launchd/src/launchd_runtime.c 2007-09-06 22:24:34 UTC (rev 23359) @@ -1036,11 +1036,18 @@ runtime_closelog(void) { if (ourlogfile) { - fflush(ourlogfile); + launchd_assumes(fflush(ourlogfile) == 0); + launchd_assumes(runtime_fsync(fileno(ourlogfile)) != -1); + } +} - if (debug_shutdown_hangs) { - fcntl(fileno(ourlogfile), F_FULLFSYNC, NULL); - } +int +runtime_fsync(int fd) +{ + if (debug_shutdown_hangs) { + return fcntl(fd, F_FULLFSYNC, NULL); + } else { + return fsync(fd); } } Modified: trunk/launchd/src/launchd_runtime.h =================================================================== --- trunk/launchd/src/launchd_runtime.h 2007-09-05 21:14:09 UTC (rev 23358) +++ trunk/launchd/src/launchd_runtime.h 2007-09-06 22:24:34 UTC (rev 23359) @@ -61,6 +61,7 @@ void launchd_runtime(void) __attribute__((noreturn)); int runtime_close(int fd); +int runtime_fsync(int fd); void runtime_set_timeout(timeout_callback to_cb, mach_msg_timeout_t to); kern_return_t runtime_add_mport(mach_port_t name, mig_callback demux, mach_msg_size_t msg_size); -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070906/508a6430/attachment.html From source_changes at macosforge.org Fri Sep 7 10:54:58 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:52 2007 Subject: [launchd-changes] [23360] trunk/launchd/src/launchd.plist.5 Message-ID: <20070907175458.9693878BFEF@cvs.opensource.apple.com> Revision: 23360 http://trac.macosforge.org/projects/launchd/changeset/23360 Author: zarzycki@apple.com Date: 2007-09-07 10:54:58 -0700 (Fri, 07 Sep 2007) Log Message: ----------- GroupName key now ignored when UserName key is not set Modified Paths: -------------- trunk/launchd/src/launchd.plist.5 Modified: trunk/launchd/src/launchd.plist.5 =================================================================== --- trunk/launchd/src/launchd.plist.5 2007-09-06 22:24:34 UTC (rev 23359) +++ trunk/launchd/src/launchd.plist.5 2007-09-07 17:54:58 UTC (rev 23360) @@ -90,6 +90,7 @@ This optional key specifies the user to run the job as. This key is only applicable when launchd is running as root. .It Sy GroupName This optional key specifies the group to run the job as. This key is only applicable when launchd is running as root. If UserName is set and GroupName is not, the the group will be set to the default group of the user. +The GroupName key is ignored without the UserName key. .It Sy inetdCompatibility The presence of this key specifies that the daemon expects to be run as if it were launched from inetd. .Bl -ohang -offset indent @@ -195,7 +196,7 @@ This optional key specifies whether the job should have .Xr initgroups 3 be called before running the job. -The default is false. +The default is true in 10.5 and false in 10.4. This key will be ignored if the UserName key is not set. .It Sy WatchPaths This optional key causes the job to be started if any one of the listed paths are modified. .It Sy QueueDirectories -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070907/fd08a6ab/attachment.html From source_changes at macosforge.org Sat Sep 8 14:56:29 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:52 2007 Subject: [launchd-changes] [23361] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070908215629.39EB678E3B4@cvs.opensource.apple.com> Revision: 23361 http://trac.macosforge.org/projects/launchd/changeset/23361 Author: zarzycki@apple.com Date: 2007-09-08 14:56:28 -0700 (Sat, 08 Sep 2007) Log Message: ----------- Leopard9A478: machine hung at shutdown with only launchd running 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-09-07 17:54:58 UTC (rev 23360) +++ trunk/launchd/src/launchd_core_logic.c 2007-09-08 21:56:28 UTC (rev 23361) @@ -4375,6 +4375,9 @@ job_log(ms->job, LOG_DEBUG, "Receive right returned to us: %s", ms->name); job_dispatch(ms->job, false); + + root_jobmgr = jobmgr_do_garbage_collection(root_jobmgr); + return true; } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070908/36fdbe36/attachment.html From source_changes at macosforge.org Sun Sep 9 12:09:56 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:52 2007 Subject: [launchd-changes] [23362] trunk/launchd/src Message-ID: <20070909190956.A17F4792EB3@cvs.opensource.apple.com> Revision: 23362 http://trac.macosforge.org/projects/launchd/changeset/23362 Author: zarzycki@apple.com Date: 2007-09-09 12:09:56 -0700 (Sun, 09 Sep 2007) Log Message: ----------- Small logging updates. Modified Paths: -------------- trunk/launchd/src/launchd_runtime.c trunk/launchd/src/launchd_runtime.h Modified: trunk/launchd/src/launchd_runtime.c =================================================================== --- trunk/launchd/src/launchd_runtime.c 2007-09-08 21:56:28 UTC (rev 23361) +++ trunk/launchd/src/launchd_runtime.c 2007-09-09 19:09:56 UTC (rev 23362) @@ -146,9 +146,6 @@ pthread_attr_setstacksize(&attr, PTHREAD_STACK_MIN); launchd_assert(pthread_create(&demand_thread, &attr, mport_demand_loop, NULL) == 0); pthread_attr_destroy(&attr); - - runtime_openlog(getprogname(), LOG_PID|LOG_CONS, LOG_LAUNCHD); - runtime_setlogmask(LOG_UPTO(/* LOG_DEBUG */ LOG_NOTICE)); } void @@ -1027,12 +1024,6 @@ static FILE *ourlogfile; void -runtime_openlog(const char *ident, int logopt, int facility) -{ - openlog(ident, logopt, facility); -} - -void runtime_closelog(void) { if (ourlogfile) { @@ -1051,7 +1042,8 @@ } } -static int internal_mask_pri; +static int internal_mask_pri = LOG_UPTO(LOG_NOTICE); +//static int internal_mask_pri = LOG_UPTO(LOG_DEBUG); int runtime_setlogmask(int maskpri) Modified: trunk/launchd/src/launchd_runtime.h =================================================================== --- trunk/launchd/src/launchd_runtime.h 2007-09-08 21:56:28 UTC (rev 23361) +++ trunk/launchd/src/launchd_runtime.h 2007-09-09 19:09:56 UTC (rev 23362) @@ -77,8 +77,6 @@ pid_t runtime_fork(mach_port_t bsport); -void runtime_openlog(const char *ident, int logopt, int facility); -void runtime_closelog(void); kern_return_t runtime_log_forward(uid_t forward_uid, gid_t forward_gid, vm_offset_t inval, mach_msg_type_number_t invalCnt); kern_return_t runtime_log_drain(mach_port_t srp, vm_offset_t *outval, mach_msg_type_number_t *outvalCnt); @@ -95,6 +93,7 @@ }; int runtime_setlogmask(int maskpri); +void runtime_closelog(void); void runtime_syslog(int pri, const char *message, ...) __attribute__((format(printf, 2, 3))); void runtime_vsyslog(struct runtime_syslog_attr *attr, const char *message, va_list args) __attribute__((format(printf, 2, 0))); -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070909/60097cfc/attachment.html From source_changes at macosforge.org Sun Sep 9 12:10:06 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:52 2007 Subject: [launchd-changes] [23363] tags/launchd-242/ Message-ID: <20070909191006.968EB792EB9@cvs.opensource.apple.com> Revision: 23363 http://trac.macosforge.org/projects/launchd/changeset/23363 Author: zarzycki@apple.com Date: 2007-09-09 12:10:06 -0700 (Sun, 09 Sep 2007) Log Message: ----------- "Tagging launchd-242 from https://svn.macosforge.org/repository/launchd/trunk" Added Paths: ----------- tags/launchd-242/ Copied: tags/launchd-242 (from rev 23362, trunk) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070909/ee1353f1/attachment.html From source_changes at macosforge.org Sun Sep 9 13:18:45 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:52 2007 Subject: [launchd-changes] [23364] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070909201845.7AEAF793811@cvs.opensource.apple.com> Revision: 23364 http://trac.macosforge.org/projects/launchd/changeset/23364 Author: zarzycki@apple.com Date: 2007-09-09 13:18:42 -0700 (Sun, 09 Sep 2007) Log Message: ----------- I am not launchd, and launchd is not me. 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-09-09 19:10:06 UTC (rev 23363) +++ trunk/launchd/src/launchd_core_logic.c 2007-09-09 20:18:42 UTC (rev 23364) @@ -3985,7 +3985,7 @@ jobmgr_log(jm, LOG_WARNING, "Stray %sprocess at shutdown: PID %u PPID %u %s", z, p_i, pp_i, n); /* - * The kernel team requested that I not do this for Leopard. + * The kernel team requested that launchd not do this for Leopard. * jobmgr_assumes(jm, kill(p_i, SIGKILL) != -1); */ } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070909/091aa172/attachment.html From source_changes at macosforge.org Mon Sep 10 11:38:15 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:52 2007 Subject: [launchd-changes] [23365] trunk/launchd/src/launchd_runtime.c Message-ID: <20070910183815.957F57994F3@cvs.opensource.apple.com> Revision: 23365 http://trac.macosforge.org/projects/launchd/changeset/23365 Author: zarzycki@apple.com Date: 2007-09-10 11:38:14 -0700 (Mon, 10 Sep 2007) Log Message: ----------- Better error reporting. Modified Paths: -------------- trunk/launchd/src/launchd_runtime.c Modified: trunk/launchd/src/launchd_runtime.c =================================================================== --- trunk/launchd/src/launchd_runtime.c 2007-09-09 20:18:42 UTC (rev 23364) +++ trunk/launchd/src/launchd_runtime.c 2007-09-10 18:38:14 UTC (rev 23365) @@ -1269,7 +1269,7 @@ tmp_port = drain_reply_port; drain_reply_port = MACH_PORT_NULL; - if (!launchd_assumes(job_mig_log_drain_reply(tmp_port, 0, outval, outvalCnt) == 0)) { + if (!launchd_assumes((errno = job_mig_log_drain_reply(tmp_port, 0, outval, outvalCnt)) == 0)) { launchd_assumes(launchd_mport_deallocate(tmp_port) == KERN_SUCCESS); } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070910/49aa6474/attachment.html From source_changes at macosforge.org Mon Sep 10 13:40:30 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:52 2007 Subject: [launchd-changes] [23366] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070910204030.5544579B318@cvs.opensource.apple.com> Revision: 23366 http://trac.macosforge.org/projects/launchd/changeset/23366 Author: zarzycki@apple.com Date: 2007-09-10 13:40:29 -0700 (Mon, 10 Sep 2007) Log Message: ----------- GroupName key now ignored when UserName key is not set 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-09-10 18:38:14 UTC (rev 23365) +++ trunk/launchd/src/launchd_core_logic.c 2007-09-10 20:40:29 UTC (rev 23366) @@ -2619,6 +2619,14 @@ return; } + /* + * I contend that having UID == 0 and GID != 0 is of dubious value. + * Nevertheless, this used to work in Tiger. See: 5425348 + */ + if (j->groupname && !j->username) { + j->username = "root"; + } + if (j->username) { if ((pwe = getpwnam(j->username)) == NULL) { job_log(j, LOG_ERR, "getpwnam(\"%s\") failed", j->username); -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070910/266896c8/attachment.html From source_changes at macosforge.org Mon Sep 10 13:41:56 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:52 2007 Subject: [launchd-changes] [23367] trunk/launchd/src/launchd.plist.5 Message-ID: <20070910204156.B66CB79B330@cvs.opensource.apple.com> Revision: 23367 http://trac.macosforge.org/projects/launchd/changeset/23367 Author: zarzycki@apple.com Date: 2007-09-10 13:41:56 -0700 (Mon, 10 Sep 2007) Log Message: ----------- GroupName key now ignored when UserName key is not set Modified Paths: -------------- trunk/launchd/src/launchd.plist.5 Modified: trunk/launchd/src/launchd.plist.5 =================================================================== --- trunk/launchd/src/launchd.plist.5 2007-09-10 20:40:29 UTC (rev 23366) +++ trunk/launchd/src/launchd.plist.5 2007-09-10 20:41:56 UTC (rev 23367) @@ -90,7 +90,6 @@ This optional key specifies the user to run the job as. This key is only applicable when launchd is running as root. .It Sy GroupName This optional key specifies the group to run the job as. This key is only applicable when launchd is running as root. If UserName is set and GroupName is not, the the group will be set to the default group of the user. -The GroupName key is ignored without the UserName key. .It Sy inetdCompatibility The presence of this key specifies that the daemon expects to be run as if it were launched from inetd. .Bl -ohang -offset indent -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070910/98feed6b/attachment.html From source_changes at macosforge.org Mon Sep 10 13:43:52 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:52 2007 Subject: [launchd-changes] [23368] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070910204352.6C5BE79B346@cvs.opensource.apple.com> Revision: 23368 http://trac.macosforge.org/projects/launchd/changeset/23368 Author: zarzycki@apple.com Date: 2007-09-10 13:43:52 -0700 (Mon, 10 Sep 2007) Log Message: ----------- We only need/want the "Still alive" check if launchd has been idle for a while... 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-09-10 20:41:56 UTC (rev 23367) +++ trunk/launchd/src/launchd_core_logic.c 2007-09-10 20:43:52 UTC (rev 23368) @@ -639,6 +639,14 @@ return r; } +static void +still_alive_with_check(void) +{ + jobmgr_log(root_jobmgr, LOG_NOTICE, "Still alive with %u children.", total_children); + + runtime_closelog(); /* hack to flush logs */ +} + jobmgr_t jobmgr_shutdown(jobmgr_t jm) { @@ -662,7 +670,7 @@ } if (debug_shutdown_hangs && jm->parentmgr == NULL && getpid() == 1) { - jobmgr_assumes(jm, kevent_mod((uintptr_t)jm, EVFILT_TIMER, EV_ADD, NOTE_SECONDS, 3, jm) != -1); + runtime_set_timeout(still_alive_with_check, 3000); } return jobmgr_do_garbage_collection(jm); @@ -2241,11 +2249,8 @@ jobmgr_dispatch_all_semaphores(jm); break; case EVFILT_TIMER: - if (kev->ident == (uintptr_t)&sorted_calendar_events) { + if (jobmgr_assumes(jm, kev->ident == (uintptr_t)&sorted_calendar_events)) { calendarinterval_callback(); - } else { - jobmgr_log(jm, LOG_NOTICE, "Still alive with %u children.", total_children); - runtime_closelog(); /* hack to flush logs */ } break; default: -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070910/dd8224fc/attachment.html From source_changes at macosforge.org Tue Sep 11 13:05:16 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:52 2007 Subject: [launchd-changes] [23369] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070911200516.1423F7A4848@cvs.opensource.apple.com> Revision: 23369 http://trac.macosforge.org/projects/launchd/changeset/23369 Author: zarzycki@apple.com Date: 2007-09-11 13:05:15 -0700 (Tue, 11 Sep 2007) Log Message: ----------- modifying the date/time confuses launchd's timers 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-09-10 20:43:52 UTC (rev 23368) +++ trunk/launchd/src/launchd_core_logic.c 2007-09-11 20:05:15 UTC (rev 23369) @@ -23,6 +23,7 @@ #include #include +#include #include #include #include @@ -348,8 +349,8 @@ unsigned int exit_timeout; int stdout_err_fd; struct timeval sent_sigterm_time; - time_t start_time; - time_t min_run_time; + uint64_t start_time; + uint32_t min_run_time; unsigned int start_interval; 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, @@ -2284,15 +2285,20 @@ void job_start(job_t j) { + static mach_timebase_info_data_t tbi; + uint64_t td, tnow = mach_absolute_time(); int spair[2]; int execspair[2]; int oepair[2]; char nbuf[64]; pid_t c; bool sipc = false; - time_t td; u_int proc_fflags = /* NOTE_EXEC|NOTE_FORK| */ NOTE_EXIT /* |NOTE_REAP */; + if (tbi.denom == 0) { + launchd_assert(mach_timebase_info(&tbi) == 0); + } + if (!job_assumes(j, j->mgr != NULL)) { return; } @@ -2302,7 +2308,8 @@ return; } - td = time(NULL) - j->start_time; + td = (tnow - j->start_time) * tbi.numer / tbi.denom; + td /= NSEC_PER_SEC; if (td < j->min_run_time && !j->legacy_mach_job && !j->inetcompat) { time_t respawn_delta = j->min_run_time - td; @@ -2334,7 +2341,7 @@ job_assumes(j, kevent_mod(j->log_redirect_fd, EVFILT_READ, EV_ADD, 0, 0, j) != -1); } - time(&j->start_time); + j->start_time = tnow; switch (c = runtime_fork(j->weird_bootstrap ? j->j_port : j->mgr->jm_port)) { case -1: -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070911/b395a59c/attachment.html From source_changes at macosforge.org Tue Sep 11 13:15:17 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:53 2007 Subject: [launchd-changes] [23370] tags/launchd-243/ Message-ID: <20070911201517.6DC727A4A7A@cvs.opensource.apple.com> Revision: 23370 http://trac.macosforge.org/projects/launchd/changeset/23370 Author: zarzycki@apple.com Date: 2007-09-11 13:15:17 -0700 (Tue, 11 Sep 2007) Log Message: ----------- "Tagging launchd-243 from https://svn.macosforge.org/repository/launchd/trunk" Added Paths: ----------- tags/launchd-243/ Copied: tags/launchd-243 (from rev 23369, trunk) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070911/de5a85b0/attachment.html From source_changes at macosforge.org Tue Sep 11 16:44:27 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:53 2007 Subject: [launchd-changes] [23371] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070911234427.F353E7A5A3F@cvs.opensource.apple.com> Revision: 23371 http://trac.macosforge.org/projects/launchd/changeset/23371 Author: zarzycki@apple.com Date: 2007-09-11 16:44:27 -0700 (Tue, 11 Sep 2007) Log Message: ----------- More wall-clock versus absolute-clock fun... 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-09-11 20:15:17 UTC (rev 23370) +++ trunk/launchd/src/launchd_core_logic.c 2007-09-11 23:44:27 UTC (rev 23371) @@ -348,7 +348,7 @@ unsigned int timeout; unsigned int exit_timeout; int stdout_err_fd; - struct timeval sent_sigterm_time; + uint64_t sent_sigterm_time; uint64_t start_time; uint32_t min_run_time; unsigned int start_interval; @@ -447,12 +447,14 @@ static size_t our_strhash(const char *s) __attribute__((pure)); static void extract_rcsid_substr(const char *i, char *o, size_t osz); static void do_first_per_user_launchd_hack(void); +static void do_file_init(void) __attribute__((constructor)); /* file local globals */ static unsigned int total_children; static mach_port_t the_exception_server; static bool did_first_per_user_launchd_BootCache_hack; static jobmgr_t background_jobmgr; +static mach_timebase_info_data_t tbi; /* process wide globals */ mach_port_t inherited_bootstrap_port; @@ -522,7 +524,7 @@ } job_assumes(j, kill(j->p, SIGTERM) != -1); - job_assumes(j, gettimeofday(&j->sent_sigterm_time, NULL) != -1); + j->sent_sigterm_time = mach_absolute_time(); if (j->exit_timeout) { job_assumes(j, kevent_mod((uintptr_t)&j->exit_timeout, EVFILT_TIMER, @@ -1898,7 +1900,6 @@ void job_reap(job_t j) { - struct timeval tve, tvd; struct rusage ru; int status; @@ -1943,19 +1944,20 @@ total_children--; LIST_REMOVE(j, pid_hash_sle); - 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) { - timersub(&tve, &j->sent_sigterm_time, &tvd); + if (j->sent_sigterm_time) { + uint64_t td_sec, td_usec, td = (mach_absolute_time() - j->sent_sigterm_time) * tbi.numer / tbi.denom; - job_log(j, LOG_INFO, "Exited %ld.%06d seconds after %s was sent", - tvd.tv_sec, tvd.tv_usec, signal_to_C_name(j->sent_sigkill ? SIGKILL : SIGTERM)); + td_sec = td / NSEC_PER_SEC; + td_usec = (td % NSEC_PER_SEC) / NSEC_PER_USEC; + + job_log(j, LOG_INFO, "Exited %lld.%06lld seconds after %s was sent", + td_sec, td_usec, signal_to_C_name(j->sent_sigkill ? SIGKILL : SIGTERM)); } #if DO_RUSAGE_SUMMATION @@ -2175,12 +2177,12 @@ job_dispatch(j, false); } else if (&j->exit_timeout == ident) { if (j->sent_sigkill) { - struct timeval tvd, tve; + uint64_t td = (mach_absolute_time() - j->sent_sigterm_time) * tbi.numer / tbi.denom; - job_assumes(j, gettimeofday(&tve, NULL) != -1); - timersub(&tve, &j->sent_sigterm_time, &tvd); - tvd.tv_sec -= j->exit_timeout; - job_log(j, LOG_ERR, "Did not die after sending SIGKILL %lu seconds ago...", tvd.tv_sec); + td /= NSEC_PER_SEC; + td -= j->exit_timeout; + + job_log(j, LOG_ERR, "Did not die after sending SIGKILL %llu seconds ago...", td); } else { job_force_sampletool(j); if (j->debug_before_kill) { @@ -2285,7 +2287,6 @@ void job_start(job_t j) { - static mach_timebase_info_data_t tbi; uint64_t td, tnow = mach_absolute_time(); int spair[2]; int execspair[2]; @@ -2295,10 +2296,6 @@ bool sipc = false; u_int proc_fflags = /* NOTE_EXEC|NOTE_FORK| */ NOTE_EXIT /* |NOTE_REAP */; - if (tbi.denom == 0) { - launchd_assert(mach_timebase_info(&tbi) == 0); - } - if (!job_assumes(j, j->mgr != NULL)) { return; } @@ -2320,8 +2317,7 @@ return; } - j->sent_sigterm_time.tv_sec = 0; - j->sent_sigterm_time.tv_usec = 0; + j->sent_sigterm_time = 0; if (!j->legacy_mach_job) { sipc = (!SLIST_EMPTY(&j->sockets) || !SLIST_EMPTY(&j->machservices)); @@ -6324,3 +6320,10 @@ free(w4r); } + +void +do_file_init(void) +{ + launchd_assert(mach_timebase_info(&tbi) == 0); + +} -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070911/71492a91/attachment.html From source_changes at macosforge.org Tue Sep 11 16:49:03 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:53 2007 Subject: [launchd-changes] [23372] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070911234903.1BA6E7A5A4B@cvs.opensource.apple.com> Revision: 23372 http://trac.macosforge.org/projects/launchd/changeset/23372 Author: zarzycki@apple.com Date: 2007-09-11 16:49:02 -0700 (Tue, 11 Sep 2007) Log Message: ----------- Comments are good. 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-09-11 23:44:27 UTC (rev 23371) +++ trunk/launchd/src/launchd_core_logic.c 2007-09-11 23:49:02 UTC (rev 23372) @@ -2305,6 +2305,11 @@ return; } + /* + * Some users adjust the wall-clock and then expect software to not notice. + * Therefore, launchd must use an absolute clock instead of gettimeofday() + * or time() wherever possible. + */ td = (tnow - j->start_time) * tbi.numer / tbi.denom; td /= NSEC_PER_SEC; -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070911/a06ad1aa/attachment.html From source_changes at macosforge.org Wed Sep 12 12:50:15 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:53 2007 Subject: [launchd-changes] [23373] trunk/launchd/src/launchd_runtime.c Message-ID: <20070912195015.5DC207ABF51@cvs.opensource.apple.com> Revision: 23373 http://trac.macosforge.org/projects/launchd/changeset/23373 Author: zarzycki@apple.com Date: 2007-09-12 12:50:15 -0700 (Wed, 12 Sep 2007) Log Message: ----------- Better error reporting. Modified Paths: -------------- trunk/launchd/src/launchd_runtime.c Modified: trunk/launchd/src/launchd_runtime.c =================================================================== --- trunk/launchd/src/launchd_runtime.c 2007-09-11 23:49:02 UTC (rev 23372) +++ trunk/launchd/src/launchd_runtime.c 2007-09-12 19:50:15 UTC (rev 23373) @@ -439,7 +439,7 @@ struct kevent kev; unsigned int i; - if (!launchd_assumes(mach_port_get_set_status(mach_task_self(), demand_port_set, &members, &membersCnt) == KERN_SUCCESS)) { + if (!launchd_assumes((errno = mach_port_get_set_status(mach_task_self(), demand_port_set, &members, &membersCnt)) == KERN_SUCCESS)) { return 1; } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070912/961b6d49/attachment.html From source_changes at macosforge.org Wed Sep 12 17:24:55 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:53 2007 Subject: [launchd-changes] [23374] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070913002455.46F237ADDCA@cvs.opensource.apple.com> Revision: 23374 http://trac.macosforge.org/projects/launchd/changeset/23374 Author: zarzycki@apple.com Date: 2007-09-12 17:24:54 -0700 (Wed, 12 Sep 2007) Log Message: ----------- 'ssh localhost sudo launchctl' kills machine 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-09-12 19:50:15 UTC (rev 23373) +++ trunk/launchd/src/launchd_core_logic.c 2007-09-13 00:24:54 UTC (rev 23374) @@ -454,6 +454,7 @@ static mach_port_t the_exception_server; static bool did_first_per_user_launchd_BootCache_hack; static jobmgr_t background_jobmgr; +static job_t workaround_5477111; static mach_timebase_info_data_t tbi; /* process wide globals */ @@ -1858,11 +1859,19 @@ void job_mig_destructor(job_t j) { - if (j && j->unload_at_mig_return) { + /* + * 5477111 + * + * 'j' can be invalid at this point. We should fix this up after Leopard ships. + */ + + if (j && j != workaround_5477111 && j->unload_at_mig_return) { job_log(j, LOG_NOTICE, "Unloading PID %u at MIG return.", j->p); job_remove(j); } + workaround_5477111 = NULL; + calendarinterval_sanity_check(); } @@ -5968,6 +5977,8 @@ jm->req_port = 0; jm->jm_port = 0; + workaround_5477111 = j; + jobmgr_shutdown(jm); return BOOTSTRAP_SUCCESS; -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070912/f5e5ee38/attachment.html From source_changes at macosforge.org Wed Sep 12 17:35:58 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:53 2007 Subject: [launchd-changes] [23375] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070913003558.1B4957ADDFB@cvs.opensource.apple.com> Revision: 23375 http://trac.macosforge.org/projects/launchd/changeset/23375 Author: zarzycki@apple.com Date: 2007-09-12 17:35:57 -0700 (Wed, 12 Sep 2007) Log Message: ----------- What's more fun than one way of reporting errors? Two ways! 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-09-13 00:24:54 UTC (rev 23374) +++ trunk/launchd/src/launchd_core_logic.c 2007-09-13 00:35:57 UTC (rev 23375) @@ -1834,7 +1834,7 @@ mib[3] = ldc.pid; - if (jobmgr_assumes(root_jobmgr, sysctl(mib, 4, &kp, &len, NULL, 0) != -1)) { + if (jobmgr_assumes(root_jobmgr, sysctl(mib, 4, &kp, &len, NULL, 0) != -1) && jobmgr_assumes(root_jobmgr, len == sizeof(kp))) { jobmgr_log(root_jobmgr, LOG_ERR, "%s() was confused by PID %u UID %u EUID %u Mach Port 0x%x: %s", __func__, ldc.pid, ldc.uid, ldc.euid, p, kp.kp_proc.p_comm); } } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070912/271a5c2f/attachment.html From source_changes at macosforge.org Wed Sep 12 17:48:46 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:53 2007 Subject: [launchd-changes] [23376] trunk/launchd/src Message-ID: <20070913004846.C97BE7ADE2B@cvs.opensource.apple.com> Revision: 23376 http://trac.macosforge.org/projects/launchd/changeset/23376 Author: zarzycki@apple.com Date: 2007-09-12 17:48:46 -0700 (Wed, 12 Sep 2007) Log Message: ----------- The per-user launchd needs to idle exit Modified Paths: -------------- trunk/launchd/src/launchd_core_logic.c trunk/launchd/src/launchd_runtime.c trunk/launchd/src/launchd_runtime.h Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2007-09-13 00:35:57 UTC (rev 23375) +++ trunk/launchd/src/launchd_core_logic.c 2007-09-13 00:48:46 UTC (rev 23376) @@ -93,7 +93,6 @@ #include "job_reply.h" #define LAUNCHD_MIN_JOB_RUN_TIME 10 -#define LAUNCHD_ADVISABLE_IDLE_TIMEOUT 30 #define LAUNCHD_DEFAULT_EXIT_TIMEOUT 20 #define LAUNCHD_SIGKILL_TIMER 5 @@ -450,7 +449,7 @@ static void do_file_init(void) __attribute__((constructor)); /* file local globals */ -static unsigned int total_children; +static size_t total_children; static mach_port_t the_exception_server; static bool did_first_per_user_launchd_BootCache_hack; static jobmgr_t background_jobmgr; @@ -646,7 +645,7 @@ static void still_alive_with_check(void) { - jobmgr_log(root_jobmgr, LOG_NOTICE, "Still alive with %u children.", total_children); + jobmgr_log(root_jobmgr, LOG_NOTICE, "Still alive with %lu children.", total_children); runtime_closelog(); /* hack to flush logs */ } @@ -740,6 +739,10 @@ struct mspolicy *msp; struct envitem *ei; + if (j == workaround_5477111) { + job_log(j, LOG_NOTICE, "@@@@@ Tried to remove ahead of schedule!"); + } + if (j->p && j->anonymous) { job_reap(j); } else if (j->p) { @@ -837,6 +840,7 @@ free(j->j_binpref); } if (j->start_interval) { + runtime_del_ref(); job_assumes(j, kevent_mod((uintptr_t)&j->start_interval, EVFILT_TIMER, EV_DELETE, 0, 0, NULL) != -1); } @@ -1122,7 +1126,7 @@ j->kqjob_callback = job_callback; j->mgr = jm; j->min_run_time = LAUNCHD_MIN_JOB_RUN_TIME; - j->timeout = LAUNCHD_ADVISABLE_IDLE_TIMEOUT; + j->timeout = RUNTIME_ADVISABLE_IDLE_TIMEOUT; j->exit_timeout = LAUNCHD_DEFAULT_EXIT_TIMEOUT; j->currently_ignored = true; j->ondemand = true; @@ -1460,6 +1464,7 @@ if (value <= 0) { job_log(j, LOG_WARNING, "StartInterval is not greater than zero, ignoring"); } else { + runtime_add_ref(); j->start_interval = value; } if (-1 == kevent_mod((uintptr_t)&j->start_interval, EVFILT_TIMER, EV_ADD, NOTE_SECONDS, value, j)) { @@ -1950,6 +1955,9 @@ kevent_mod((uintptr_t)&j->exit_timeout, EVFILT_TIMER, EV_DELETE, 0, 0, NULL); } + if (!j->anonymous) { + runtime_del_ref(); + } total_children--; LIST_REMOVE(j, pid_hash_sle); @@ -2388,6 +2396,7 @@ j->start_pending = false; + runtime_add_ref(); total_children++; LIST_INSERT_HEAD(&j->mgr->active_jobs[ACTIVE_JOB_HASH(c)], j, pid_hash_sle); @@ -3262,6 +3271,8 @@ calendarinterval_setalarm(j, ci); + runtime_add_ref(); + return true; } @@ -3272,6 +3283,8 @@ LIST_REMOVE(ci, global_sle); free(ci); + + runtime_del_ref(); } void @@ -3329,6 +3342,8 @@ SLIST_INSERT_HEAD(&j->sockets, sg, sle); + runtime_add_ref(); + return true; } @@ -3345,6 +3360,8 @@ free(sg->fds); free(sg); + + runtime_del_ref(); } void @@ -3542,7 +3559,7 @@ job_log(j, LOG_DEBUG, "Exited while removal was pending."); return true; } else if (j->mgr->shutting_down) { - job_log(j, LOG_DEBUG, "Exited while shutdown in progress. Processes remaining: %u", total_children); + job_log(j, LOG_DEBUG, "Exited while shutdown in progress. Processes remaining: %lu", total_children); return true; } else if (j->legacy_mach_job) { if (SLIST_EMPTY(&j->machservices)) { @@ -4559,6 +4576,8 @@ SLIST_INSERT_HEAD(&j->semaphores, si, sle); + runtime_add_ref(); + return true; } @@ -4572,6 +4591,8 @@ } free(si); + + runtime_del_ref(); } void @@ -5122,10 +5143,16 @@ break; case VPROC_GSK_START_INTERVAL: if ((unsigned int)inval > 0) { + if (j->start_interval == 0) { + runtime_add_ref(); + } j->start_interval = inval; job_assumes(j, kevent_mod((uintptr_t)&j->start_interval, EVFILT_TIMER, EV_ADD, NOTE_SECONDS, j->start_interval, j) != -1); } else if (j->start_interval) { job_assumes(j, kevent_mod((uintptr_t)&j->start_interval, EVFILT_TIMER, EV_DELETE, 0, 0, NULL) != -1); + if (j->start_interval != 0) { + runtime_del_ref(); + } j->start_interval = 0; } break; Modified: trunk/launchd/src/launchd_runtime.c =================================================================== --- trunk/launchd/src/launchd_runtime.c 2007-09-13 00:35:57 UTC (rev 23375) +++ trunk/launchd/src/launchd_runtime.c 2007-09-13 00:48:46 UTC (rev 23376) @@ -90,9 +90,10 @@ static mach_msg_size_t max_msg_size; static mig_callback *mig_cb_table; static size_t mig_cb_table_sz; -static timeout_callback runtime_idle_callback; -static mach_msg_timeout_t runtime_idle_timeout; +static timeout_callback runtime_idle_callback = launchd_shutdown; +static mach_msg_timeout_t runtime_idle_timeout = RUNTIME_ADVISABLE_IDLE_TIMEOUT * 1000; static audit_token_t *au_tok; +static size_t runtime_busy_cnt; static STAILQ_HEAD(, logmsg_s) logmsg_queue = STAILQ_HEAD_INITIALIZER(logmsg_queue); @@ -635,15 +636,15 @@ void -runtime_set_timeout(timeout_callback to_cb, mach_msg_timeout_t to) +runtime_set_timeout(timeout_callback to_cb, unsigned int sec) { - if (to == 0 || to_cb == NULL) { + if (sec == 0 || to_cb == NULL) { runtime_idle_callback = NULL; runtime_idle_timeout = 0; } runtime_idle_callback = to_cb; - runtime_idle_timeout = to; + runtime_idle_timeout = sec * 1000; } kern_return_t @@ -911,7 +912,7 @@ } } - if ((tmp_options & MACH_RCV_MSG) && runtime_idle_callback) { + if ((tmp_options & MACH_RCV_MSG) && runtime_idle_callback && (runtime_busy_cnt == 0)) { tmp_options |= MACH_RCV_TIMEOUT; if (!(tmp_options & MACH_SEND_TIMEOUT)) { @@ -1349,3 +1350,15 @@ return runtime_log_pack(outval, outvalCnt); } + +void +runtime_add_ref(void) +{ + runtime_busy_cnt++; +} + +void +runtime_del_ref(void) +{ + runtime_busy_cnt--; +} Modified: trunk/launchd/src/launchd_runtime.h =================================================================== --- trunk/launchd/src/launchd_runtime.h 2007-09-13 00:35:57 UTC (rev 23375) +++ trunk/launchd/src/launchd_runtime.h 2007-09-13 00:48:46 UTC (rev 23376) @@ -56,6 +56,9 @@ boolean_t launchd_internal_demux(mach_msg_header_t *Request, mach_msg_header_t *Reply); +void runtime_add_ref(void); +void runtime_del_ref(void); + void launchd_runtime_init(void); void launchd_runtime_init2(void); void launchd_runtime(void) __attribute__((noreturn)); @@ -63,7 +66,9 @@ int runtime_close(int fd); int runtime_fsync(int fd); -void runtime_set_timeout(timeout_callback to_cb, mach_msg_timeout_t to); +#define RUNTIME_ADVISABLE_IDLE_TIMEOUT 30 + +void runtime_set_timeout(timeout_callback to_cb, unsigned int sec); kern_return_t runtime_add_mport(mach_port_t name, mig_callback demux, mach_msg_size_t msg_size); kern_return_t runtime_remove_mport(mach_port_t name); bool runtime_get_caller_creds(struct ldcred *ldc); -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070912/e84a22bf/attachment.html From source_changes at macosforge.org Wed Sep 12 17:50:25 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:53 2007 Subject: [launchd-changes] [23377] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070913005025.337687ADE3D@cvs.opensource.apple.com> Revision: 23377 http://trac.macosforge.org/projects/launchd/changeset/23377 Author: zarzycki@apple.com Date: 2007-09-12 17:50:24 -0700 (Wed, 12 Sep 2007) Log Message: ----------- Some debug code slipped into the last commit. 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-09-13 00:48:46 UTC (rev 23376) +++ trunk/launchd/src/launchd_core_logic.c 2007-09-13 00:50:24 UTC (rev 23377) @@ -739,10 +739,6 @@ struct mspolicy *msp; struct envitem *ei; - if (j == workaround_5477111) { - job_log(j, LOG_NOTICE, "@@@@@ Tried to remove ahead of schedule!"); - } - if (j->p && j->anonymous) { job_reap(j); } else if (j->p) { -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070912/a491b954/attachment.html From source_changes at macosforge.org Thu Sep 13 10:16:54 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:53 2007 Subject: [launchd-changes] [23378] trunk/launchd/src Message-ID: <20070913171654.A2B237AF431@cvs.opensource.apple.com> Revision: 23378 http://trac.macosforge.org/projects/launchd/changeset/23378 Author: zarzycki@apple.com Date: 2007-09-13 10:16:54 -0700 (Thu, 13 Sep 2007) Log Message: ----------- White space clean up. Modified Paths: -------------- trunk/launchd/src/launchctl.c trunk/launchd/src/launchd.c trunk/launchd/src/launchd_core_logic.c trunk/launchd/src/launchd_runtime.c trunk/launchd/src/launchproxy.c trunk/launchd/src/liblaunch.c Modified: trunk/launchd/src/launchctl.c =================================================================== --- trunk/launchd/src/launchctl.c 2007-09-13 00:50:24 UTC (rev 23377) +++ trunk/launchd/src/launchctl.c 2007-09-13 17:16:54 UTC (rev 23378) @@ -81,8 +81,8 @@ #define MACHINIT_JOBKEY_SERVERPORT "ServerPort" #define MACHINIT_JOBKEY_SERVICEPORT "ServicePort" -#define assumes(e) \ - (__builtin_expect(!(e), 0) ? _log_launchctl_bug(__rcs_file_version__, __FILE__, __LINE__, #e), false : true) +#define assumes(e) \ + (__builtin_expect(!(e), 0) ? _log_launchctl_bug(__rcs_file_version__, __FILE__, __LINE__, #e), false : true) struct load_unload_state { @@ -738,7 +738,7 @@ } if (!(S_ISREG(sb.st_mode) || S_ISDIR(sb.st_mode))) { - fprintf(stderr, "%s: Dubious path. Not a regular file or directory (skipping): %s\n", getprogname(), path); + fprintf(stderr, "%s: Dubious path. Not a regular file or directory (skipping): %s\n", getprogname(), path); return false; } @@ -894,9 +894,9 @@ setm = true; } - if (passive) { + if (passive) { if (unlink(sun.sun_path) == -1 && errno != ENOENT) { - close(sfd); + close(sfd); return; } oldmask = umask(S_IRWXG|S_IRWXO); @@ -1621,7 +1621,7 @@ int load_and_unload_cmd(int argc, char *const argv[]) { - NSSearchPathEnumerationState es = 0; + NSSearchPathEnumerationState es = 0; char nspath[PATH_MAX * 2]; /* safe side, we need to append */ bool badopts = false; struct load_unload_state lus; @@ -2595,7 +2595,7 @@ is_legacy_mach_job(launch_data_t obj) { bool has_servicename = launch_data_dict_lookup(obj, MACHINIT_JOBKEY_SERVICENAME); - bool has_command = launch_data_dict_lookup(obj, MACHINIT_JOBKEY_COMMAND); + bool has_command = launch_data_dict_lookup(obj, MACHINIT_JOBKEY_COMMAND); bool has_label = launch_data_dict_lookup(obj, LAUNCH_JOBKEY_LABEL); return has_command && has_servicename && !has_label; Modified: trunk/launchd/src/launchd.c =================================================================== --- trunk/launchd/src/launchd.c 2007-09-13 00:50:24 UTC (rev 23377) +++ trunk/launchd/src/launchd.c 2007-09-13 17:16:54 UTC (rev 23378) @@ -115,7 +115,7 @@ while ((ch = getopt(argc, argv, "s")) != -1) { switch (ch) { - case 's': sflag = true; break; /* single user */ + case 's': sflag = true; break; /* single user */ case '?': /* we should do something with the global optopt variable here */ default: fprintf(stderr, "%s: ignoring unknown arguments\n", getprogname()); Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2007-09-13 00:50:24 UTC (rev 23377) +++ trunk/launchd/src/launchd_core_logic.c 2007-09-13 17:16:54 UTC (rev 23378) @@ -273,8 +273,8 @@ char name[0]; }; -#define jobmgr_assumes(jm, e) \ - (__builtin_expect(!(e), 0) ? jobmgr_log_bug(jm, __rcs_file_version__, __FILE__, __LINE__, #e), false : true) +#define jobmgr_assumes(jm, e) \ + (__builtin_expect(!(e), 0) ? jobmgr_log_bug(jm, __rcs_file_version__, __FILE__, __LINE__, #e), false : true) static jobmgr_t jobmgr_new(jobmgr_t jm, mach_port_t requestorport, mach_port_t transfer_port, bool sflag, const char *name); static job_t jobmgr_import2(jobmgr_t jm, launch_data_t pload); @@ -369,8 +369,8 @@ static size_t hash_ms(const char *msstr) __attribute__((pure)); -#define job_assumes(j, e) \ - (__builtin_expect(!(e), 0) ? job_log_bug(j, __rcs_file_version__, __FILE__, __LINE__, #e), false : true) +#define job_assumes(j, e) \ + (__builtin_expect(!(e), 0) ? job_log_bug(j, __rcs_file_version__, __FILE__, __LINE__, #e), false : true) static void job_import_keys(launch_data_t obj, const char *key, void *context); static void job_import_bool(job_t j, const char *key, bool value); @@ -421,15 +421,15 @@ const char *key; int val; } launchd_keys2limits[] = { - { LAUNCH_JOBKEY_RESOURCELIMIT_CORE, RLIMIT_CORE }, - { LAUNCH_JOBKEY_RESOURCELIMIT_CPU, RLIMIT_CPU }, - { LAUNCH_JOBKEY_RESOURCELIMIT_DATA, RLIMIT_DATA }, - { LAUNCH_JOBKEY_RESOURCELIMIT_FSIZE, RLIMIT_FSIZE }, - { LAUNCH_JOBKEY_RESOURCELIMIT_MEMLOCK, RLIMIT_MEMLOCK }, - { LAUNCH_JOBKEY_RESOURCELIMIT_NOFILE, RLIMIT_NOFILE }, - { LAUNCH_JOBKEY_RESOURCELIMIT_NPROC, RLIMIT_NPROC }, - { LAUNCH_JOBKEY_RESOURCELIMIT_RSS, RLIMIT_RSS }, - { LAUNCH_JOBKEY_RESOURCELIMIT_STACK, RLIMIT_STACK }, + { LAUNCH_JOBKEY_RESOURCELIMIT_CORE, RLIMIT_CORE }, + { LAUNCH_JOBKEY_RESOURCELIMIT_CPU, RLIMIT_CPU }, + { LAUNCH_JOBKEY_RESOURCELIMIT_DATA, RLIMIT_DATA }, + { LAUNCH_JOBKEY_RESOURCELIMIT_FSIZE, RLIMIT_FSIZE }, + { LAUNCH_JOBKEY_RESOURCELIMIT_MEMLOCK, RLIMIT_MEMLOCK }, + { LAUNCH_JOBKEY_RESOURCELIMIT_NOFILE, RLIMIT_NOFILE }, + { LAUNCH_JOBKEY_RESOURCELIMIT_NPROC, RLIMIT_NPROC }, + { LAUNCH_JOBKEY_RESOURCELIMIT_RSS, RLIMIT_RSS }, + { LAUNCH_JOBKEY_RESOURCELIMIT_STACK, RLIMIT_STACK }, }; static time_t cronemu(int mon, int mday, int hour, int min); @@ -716,7 +716,7 @@ } else if (getpid() == 1) { jobmgr_log(jm, LOG_DEBUG, "About to call: reboot(%s)", reboot_flags_to_C_names(jm->reboot_flags)); runtime_closelog(); - jobmgr_assumes(jm, reboot(jm->reboot_flags) != -1); + jobmgr_assumes(jm, reboot(jm->reboot_flags) != -1); runtime_closelog(); } else { runtime_closelog(); @@ -3070,9 +3070,9 @@ } } -void +void semaphoreitem_ignore(job_t j, struct semaphoreitem *si) -{ +{ if (si->fd != -1) { job_log(j, LOG_DEBUG, "Ignoring Vnode: %d", si->fd); job_assumes(j, kevent_mod(si->fd, EVFILT_VNODE, EV_DELETE, 0, 0, NULL) != -1); @@ -4336,8 +4336,8 @@ job_assumes(ms->job, launchd_mport_notify_req(ms->port, which) == KERN_SUCCESS); } -#define NELEM(x) (sizeof(x)/sizeof(x[0])) -#define END_OF(x) (&(x)[NELEM(x)]) +#define NELEM(x) (sizeof(x)/sizeof(x[0])) +#define END_OF(x) (&(x)[NELEM(x)]) char ** mach_cmd2argv(const char *string) @@ -4737,11 +4737,11 @@ return true; } - if (mon < wtm->tm_mon) { + if (mon < wtm->tm_mon) { return false; } - if (mon > wtm->tm_mon) { + if (mon > wtm->tm_mon) { wtm->tm_mon = mon; wtm->tm_mday = 1; wtm->tm_hour = 0; @@ -4772,11 +4772,11 @@ return true; } - if (mday < wtm->tm_mday) { + if (mday < wtm->tm_mday) { return false; } - if (mday > wtm->tm_mday) { + if (mday > wtm->tm_mday) { wtm->tm_mday = mday; wtm->tm_hour = 0; wtm->tm_min = 0; Modified: trunk/launchd/src/launchd_runtime.c =================================================================== --- trunk/launchd/src/launchd_runtime.c 2007-09-13 00:50:24 UTC (rev 23377) +++ trunk/launchd/src/launchd_runtime.c 2007-09-13 17:16:54 UTC (rev 23378) @@ -142,7 +142,7 @@ launchd_assert(pthread_create(&kqueue_demand_thread, &attr, kqueue_demand_loop, NULL) == 0); pthread_attr_destroy(&attr); - pthread_attr_init(&attr); + pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); pthread_attr_setstacksize(&attr, PTHREAD_STACK_MIN); launchd_assert(pthread_create(&demand_thread, &attr, mport_demand_loop, NULL) == 0); @@ -1173,7 +1173,7 @@ char *data_off; struct logmsg_s *lm; -#define ROUND_TO_64BIT_WORD_SIZE(x) ((x + 7) & ~7) +#define ROUND_TO_64BIT_WORD_SIZE(x) ((x + 7) & ~7) /* we do this to make the unpacking for the log_drain cause unalignment faults */ lm_sz = ROUND_TO_64BIT_WORD_SIZE(lm_sz); Modified: trunk/launchd/src/launchproxy.c =================================================================== --- trunk/launchd/src/launchproxy.c 2007-09-13 00:50:24 UTC (rev 23377) +++ trunk/launchd/src/launchproxy.c 2007-09-13 17:16:54 UTC (rev 23378) @@ -48,12 +48,12 @@ static void find_fds(launch_data_t o, const char *key __attribute__((unused)), void *context __attribute__((unused))) { - struct kevent kev; - size_t i; + struct kevent kev; + size_t i; int fd; - switch (launch_data_get_type(o)) { - case LAUNCH_DATA_FD: + switch (launch_data_get_type(o)) { + case LAUNCH_DATA_FD: fd = launch_data_get_fd(o); if (-1 == fd) break; @@ -61,17 +61,17 @@ EV_SET(&kev, fd, EVFILT_READ, EV_ADD, 0, 0, NULL); if (kevent(kq, &kev, 1, NULL, 0, NULL) == -1) syslog(LOG_DEBUG, "kevent(%d): %m", fd); - break; - case LAUNCH_DATA_ARRAY: - for (i = 0; i < launch_data_array_get_count(o); i++) - find_fds(launch_data_array_get_index(o, i), NULL, NULL); - break; - case LAUNCH_DATA_DICTIONARY: - launch_data_dict_iterate(o, find_fds, NULL); - break; - default: - break; - } + break; + case LAUNCH_DATA_ARRAY: + for (i = 0; i < launch_data_array_get_count(o); i++) + find_fds(launch_data_array_get_index(o, i), NULL, NULL); + break; + case LAUNCH_DATA_DICTIONARY: + launch_data_dict_iterate(o, find_fds, NULL); + break; + default: + break; + } } int main(int argc __attribute__((unused)), char *argv[]) Modified: trunk/launchd/src/liblaunch.c =================================================================== --- trunk/launchd/src/liblaunch.c 2007-09-13 00:50:24 UTC (rev 23377) +++ trunk/launchd/src/liblaunch.c 2007-09-13 17:16:54 UTC (rev 23378) @@ -372,7 +372,7 @@ launch_data_array_pop_first(launch_data_t where) { launch_data_t r = NULL; - + if (where->_array_cnt > 0) { r = where->_array[0]; memmove(where->_array, where->_array + 1, (where->_array_cnt - 1) * sizeof(launch_data_t)); @@ -525,23 +525,23 @@ launch_t launchd_fdopen(int fd) { - launch_t c; + launch_t c; - c = calloc(1, sizeof(struct _launch)); + c = calloc(1, sizeof(struct _launch)); if (!c) return NULL; - c->fd = fd; + c->fd = fd; fcntl(fd, F_SETFL, O_NONBLOCK); - if ((c->sendbuf = malloc(0)) == NULL) + if ((c->sendbuf = malloc(0)) == NULL) goto out_bad; - if ((c->sendfds = malloc(0)) == NULL) + if ((c->sendfds = malloc(0)) == NULL) goto out_bad; - if ((c->recvbuf = malloc(0)) == NULL) + if ((c->recvbuf = malloc(0)) == NULL) goto out_bad; - if ((c->recvfds = malloc(0)) == NULL) + if ((c->recvfds = malloc(0)) == NULL) goto out_bad; return c; @@ -770,10 +770,10 @@ iov[0].iov_base = &lmh; iov[0].iov_len = sizeof(lmh); mh.msg_iov = iov; - mh.msg_iovlen = 2; + mh.msg_iovlen = 2; } else { mh.msg_iov = iov + 1; - mh.msg_iovlen = 1; + mh.msg_iovlen = 1; } iov[1].iov_base = lh->sendbuf; @@ -916,7 +916,7 @@ goto out; } while (launchd_msg_send(_lc->l, NULL) == -1); } - + while (resp == NULL) { if (d == NULL && launch_data_array_get_count(_lc->async_resp) > 0) { resp = launch_data_array_pop_first(_lc->async_resp); @@ -950,13 +950,13 @@ struct cmsghdr *cm = alloca(4096); launch_data_t rmsg = NULL; size_t data_offset, fd_offset; - struct msghdr mh; - struct iovec iov; + struct msghdr mh; + struct iovec iov; int r; - memset(&mh, 0, sizeof(mh)); - mh.msg_iov = &iov; - mh.msg_iovlen = 1; + memset(&mh, 0, sizeof(mh)); + mh.msg_iov = &iov; + mh.msg_iovlen = 1; lh->recvbuf = reallocf(lh->recvbuf, lh->recvlen + 8*1024); @@ -1099,7 +1099,7 @@ launch_data_t r = launch_data_alloc(LAUNCH_DATA_ERRNO); if (r) - launch_data_set_errno(r, e); + launch_data_set_errno(r, e); return r; } @@ -1109,7 +1109,7 @@ launch_data_t r = launch_data_alloc(LAUNCH_DATA_FD); if (r) - launch_data_set_fd(r, fd); + launch_data_set_fd(r, fd); return r; } @@ -1119,7 +1119,7 @@ launch_data_t r = launch_data_alloc(LAUNCH_DATA_MACHPORT); if (r) - launch_data_set_machport(r, p); + launch_data_set_machport(r, p); return r; } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070913/07de0c4e/attachment.html From source_changes at macosforge.org Thu Sep 13 10:40:43 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:53 2007 Subject: [launchd-changes] [23379] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070913174043.A78127AF4C7@cvs.opensource.apple.com> Revision: 23379 http://trac.macosforge.org/projects/launchd/changeset/23379 Author: zarzycki@apple.com Date: 2007-09-13 10:40:43 -0700 (Thu, 13 Sep 2007) Log Message: ----------- Smarter idle exit logic. 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-09-13 17:16:54 UTC (rev 23378) +++ trunk/launchd/src/launchd_core_logic.c 2007-09-13 17:40:43 UTC (rev 23379) @@ -250,6 +250,7 @@ static void semaphoreitem_callback(job_t j, struct kevent *kev); static void semaphoreitem_watch(job_t j, struct semaphoreitem *si); static void semaphoreitem_ignore(job_t j, struct semaphoreitem *si); +static void semaphoreitem_runtime_mod_ref(struct semaphoreitem *si, bool add); #define ACTIVE_JOB_HASH_SIZE 32 #define ACTIVE_JOB_HASH(x) (IS_POWER_OF_TWO(ACTIVE_JOB_HASH_SIZE) ? (x & (ACTIVE_JOB_HASH_SIZE - 1)) : (x % ACTIVE_JOB_HASH_SIZE)) @@ -2329,6 +2330,11 @@ if (td < j->min_run_time && !j->legacy_mach_job && !j->inetcompat) { time_t respawn_delta = j->min_run_time - td; + /* + * We technically should ref-count throttled jobs to prevent idle exit, + * but we're not directly tracking the 'throttled' state at the moment. + */ + job_log(j, LOG_WARNING, "Throttling respawn: Will start in %ld seconds", respawn_delta); job_assumes(j, kevent_mod((uintptr_t)j, EVFILT_TIMER, EV_ADD|EV_ONESHOT, NOTE_SECONDS, respawn_delta, j) != -1); job_ignore(j); @@ -4572,14 +4578,43 @@ SLIST_INSERT_HEAD(&j->semaphores, si, sle); - runtime_add_ref(); + semaphoreitem_runtime_mod_ref(si, true); return true; } void +semaphoreitem_runtime_mod_ref(struct semaphoreitem *si, bool add) +{ + /* + * External events need to be tracked. + * Internal events do NOT need to be tracked. + */ + + switch (si->why) { + case SUCCESSFUL_EXIT: + case FAILED_EXIT: + case OTHER_JOB_ENABLED: + case OTHER_JOB_DISABLED: + case OTHER_JOB_ACTIVE: + case OTHER_JOB_INACTIVE: + return; + default: + break; + } + + if (add) { + runtime_add_ref(); + } else { + runtime_del_ref(); + } +} + +void semaphoreitem_delete(job_t j, struct semaphoreitem *si) { + semaphoreitem_runtime_mod_ref(si, false); + SLIST_REMOVE(&j->semaphores, si, semaphoreitem, sle); if (si->fd != -1) { @@ -4587,8 +4622,6 @@ } free(si); - - runtime_del_ref(); } void -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070913/d9cd453f/attachment.html From source_changes at macosforge.org Thu Sep 13 10:54:03 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:53 2007 Subject: [launchd-changes] [23380] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070913175403.73BBA7AF51B@cvs.opensource.apple.com> Revision: 23380 http://trac.macosforge.org/projects/launchd/changeset/23380 Author: zarzycki@apple.com Date: 2007-09-13 10:54:03 -0700 (Thu, 13 Sep 2007) Log Message: ----------- I firmly believe that source code comments exist to document the code that is NOT there. 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-09-13 17:40:43 UTC (rev 23379) +++ trunk/launchd/src/launchd_core_logic.c 2007-09-13 17:54:03 UTC (rev 23380) @@ -2014,6 +2014,12 @@ j->last_exit_status = status; j->sent_sigkill = false; j->p = 0; + + /* + * We need to someday evaluate other jobs and find those who wish to track the + * active/inactive state of this job. The current job_dispatch() logic makes + * this messy, given that jobs can be deleted at dispatch. + */ } void -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070913/d2e394dc/attachment.html From source_changes at macosforge.org Thu Sep 13 12:11:36 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:53 2007 Subject: [launchd-changes] [23381] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070913191136.54B747AF742@cvs.opensource.apple.com> Revision: 23381 http://trac.macosforge.org/projects/launchd/changeset/23381 Author: zarzycki@apple.com Date: 2007-09-13 12:11:36 -0700 (Thu, 13 Sep 2007) Log Message: ----------- Better input vetting. 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-09-13 17:54:03 UTC (rev 23380) +++ trunk/launchd/src/launchd_core_logic.c 2007-09-13 19:11:36 UTC (rev 23381) @@ -1687,6 +1687,7 @@ job_t j; if (pload == NULL) { + errno = EINVAL; return NULL; } @@ -1695,14 +1696,21 @@ return NULL; } - if ((tmp = launch_data_dict_lookup(pload, LAUNCH_JOBKEY_LABEL)) && - (launch_data_get_type(tmp) == LAUNCH_DATA_STRING)) { - if (!(label = launch_data_get_string(tmp))) { - errno = EINVAL; - return NULL; - } + if (!(tmp = launch_data_dict_lookup(pload, LAUNCH_JOBKEY_LABEL))) { + errno = EINVAL; + return NULL; } + if (launch_data_get_type(tmp) != LAUNCH_DATA_STRING) { + errno = EINVAL; + return NULL; + } + + if (!(label = launch_data_get_string(tmp))) { + errno = EINVAL; + return NULL; + } + if ((tmp = launch_data_dict_lookup(pload, LAUNCH_JOBKEY_PROGRAM)) && (launch_data_get_type(tmp) == LAUNCH_DATA_STRING)) { prog = launch_data_get_string(tmp); -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070913/a73958ae/attachment.html From source_changes at macosforge.org Thu Sep 13 15:42:46 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:53 2007 Subject: [launchd-changes] [23382] tags/launchd-244/ Message-ID: <20070913224246.E146C7AFD1B@cvs.opensource.apple.com> Revision: 23382 http://trac.macosforge.org/projects/launchd/changeset/23382 Author: zarzycki@apple.com Date: 2007-09-13 15:42:46 -0700 (Thu, 13 Sep 2007) Log Message: ----------- "Tagging launchd-244 from https://svn.macosforge.org/repository/launchd/trunk" Added Paths: ----------- tags/launchd-244/ Copied: tags/launchd-244 (from rev 23381, trunk) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070913/8dbb656d/attachment.html From source_changes at macosforge.org Thu Sep 13 16:43:47 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:53 2007 Subject: [launchd-changes] [23383] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070913234347.AB3A57AFF16@cvs.opensource.apple.com> Revision: 23383 http://trac.macosforge.org/projects/launchd/changeset/23383 Author: zarzycki@apple.com Date: 2007-09-13 16:43:46 -0700 (Thu, 13 Sep 2007) Log Message: ----------- Performance regression due to 5418922 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-09-13 22:42:46 UTC (rev 23382) +++ trunk/launchd/src/launchd_core_logic.c 2007-09-13 23:43:46 UTC (rev 23383) @@ -2341,7 +2341,7 @@ td = (tnow - j->start_time) * tbi.numer / tbi.denom; td /= NSEC_PER_SEC; - if (td < j->min_run_time && !j->legacy_mach_job && !j->inetcompat) { + if (j->start_time && (td < j->min_run_time) && !j->legacy_mach_job && !j->inetcompat) { time_t respawn_delta = j->min_run_time - td; /* -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070913/9260908c/attachment.html From source_changes at macosforge.org Thu Sep 13 17:33:44 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:53 2007 Subject: [launchd-changes] [23384] trunk/launchd/src Message-ID: <20070914003344.6C2817B002F@cvs.opensource.apple.com> Revision: 23384 http://trac.macosforge.org/projects/launchd/changeset/23384 Author: zarzycki@apple.com Date: 2007-09-13 17:33:43 -0700 (Thu, 13 Sep 2007) Log Message: ----------- More sanity checks. Modified Paths: -------------- trunk/launchd/src/launchd_core_logic.c trunk/launchd/src/libvproc.c Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2007-09-13 23:43:46 UTC (rev 23383) +++ trunk/launchd/src/launchd_core_logic.c 2007-09-14 00:33:43 UTC (rev 23384) @@ -2333,6 +2333,8 @@ return; } + job_assumes(j, tnow > j->start_time); + /* * Some users adjust the wall-clock and then expect software to not notice. * Therefore, launchd must use an absolute clock instead of gettimeofday() Modified: trunk/launchd/src/libvproc.c =================================================================== --- trunk/launchd/src/libvproc.c 2007-09-13 23:43:46 UTC (rev 23383) +++ trunk/launchd/src/libvproc.c 2007-09-14 00:33:43 UTC (rev 23384) @@ -322,6 +322,10 @@ errno = EPERM; break; case BOOTSTRAP_NO_MEMORY: errno = ENOMEM; break; + case BOOTSTRAP_NAME_IN_USE: + errno = EEXIST; break; + case 1: + errno = EIO; break; default: errno = EINVAL; break; } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070913/d70f97b8/attachment.html From source_changes at macosforge.org Thu Sep 13 17:45:13 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:53 2007 Subject: [launchd-changes] [23385] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070914004513.82AF77B00B3@cvs.opensource.apple.com> Revision: 23385 http://trac.macosforge.org/projects/launchd/changeset/23385 Author: zarzycki@apple.com Date: 2007-09-13 17:45:13 -0700 (Thu, 13 Sep 2007) Log Message: ----------- More sanity checks. 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-09-14 00:33:43 UTC (rev 23384) +++ trunk/launchd/src/launchd_core_logic.c 2007-09-14 00:45:13 UTC (rev 23385) @@ -404,7 +404,6 @@ static job_t job_new(jobmgr_t jm, const char *label, const char *prog, const char *const *argv); static job_t job_new_via_mach_init(job_t j, const char *cmd, uid_t uid, bool ond); 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); @@ -4475,12 +4474,6 @@ return j->anonymous; } -pid_t -job_get_pid(job_t j) -{ - return j->p; -} - void job_force_sampletool(job_t j) { @@ -6220,7 +6213,7 @@ return VPROC_ERR_TRY_PER_USER; } - if (indataCnt == 0) { + if (!job_assumes(j, indataCnt != 0)) { return 1; } @@ -6229,12 +6222,14 @@ } jr = jobmgr_import2(j->mgr, input_obj); - - if (jr == NULL) switch (errno) { - case EEXIST: - return BOOTSTRAP_NAME_IN_USE; - default: - return BOOTSTRAP_NO_MEMORY; + + if (!job_assumes(j, jr != NULL)) { + switch (errno) { + case EEXIST: + return BOOTSTRAP_NAME_IN_USE; + default: + return BOOTSTRAP_NO_MEMORY; + } } job_reparent_hack(jr, NULL); @@ -6254,6 +6249,8 @@ return BOOTSTRAP_NO_MEMORY; } + job_assumes(jr, jr->p); + if (!job_setup_machport(jr)) { job_remove(jr); return BOOTSTRAP_NO_MEMORY; @@ -6261,7 +6258,7 @@ job_log(j, LOG_INFO, "Spawned"); - *child_pid = job_get_pid(jr); + *child_pid = jr->p; *obsvr_port = jr->j_port; mig_deallocate(indata, indataCnt); -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070913/07d237ee/attachment.html From source_changes at macosforge.org Thu Sep 13 18:25:49 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:53 2007 Subject: [launchd-changes] [23386] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070914012549.C14967B0186@cvs.opensource.apple.com> Revision: 23386 http://trac.macosforge.org/projects/launchd/changeset/23386 Author: zarzycki@apple.com Date: 2007-09-13 18:25:49 -0700 (Thu, 13 Sep 2007) Log Message: ----------- Not all sockets are created equal: We need to unlink Unix domain sockets before closing them 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-09-14 00:45:13 UTC (rev 23385) +++ trunk/launchd/src/launchd_core_logic.c 2007-09-14 01:25:49 UTC (rev 23386) @@ -3370,6 +3370,18 @@ unsigned int i; for (i = 0; i < sg->fd_cnt; i++) { +#if 0 + struct sockaddr_storage ss; + struct sockaddr_un *sun = (struct sockaddr_un *)&ss; + socklen_t ss_len = sizeof(ss); + + /* 5480306 */ + if (job_assumes(j, getsockname(sg->fds[i], (struct sockaddr *)&ss, &ss_len) != -1) + && job_assumes(j, ss_len > 0) && (ss.ss_family == AF_UNIX)) { + job_assumes(j, unlink(sun->sun_path) != -1); + /* We might conditionally need to delete a directory here */ + } +#endif job_assumes(j, runtime_close(sg->fds[i]) != -1); } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070913/31ab3437/attachment.html From source_changes at macosforge.org Fri Sep 14 11:45:29 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:53 2007 Subject: [launchd-changes] [23387] trunk/launchd/src/SystemStarter.c Message-ID: <20070914184529.9CD6D7B111B@cvs.opensource.apple.com> Revision: 23387 http://trac.macosforge.org/projects/launchd/changeset/23387 Author: zarzycki@apple.com Date: 2007-09-14 11:45:29 -0700 (Fri, 14 Sep 2007) Log Message: ----------- startupitem does not receive TERM signal Modified Paths: -------------- trunk/launchd/src/SystemStarter.c Modified: trunk/launchd/src/SystemStarter.c =================================================================== --- trunk/launchd/src/SystemStarter.c 2007-09-14 01:25:49 UTC (rev 23386) +++ trunk/launchd/src/SystemStarter.c 2007-09-14 18:45:29 UTC (rev 23387) @@ -47,6 +47,9 @@ static int system_starter(Action anAction, const char *aService); static void displayErrorMessages(StartupContext aStartupContext); static pid_t fwexec(const char *cmd, ...) __attribute__((sentinel)); +static void dummy_sig(int signo __attribute__((unused))) +{ +} int main(int argc, char *argv[]) @@ -60,7 +63,7 @@ EV_SET(&kev, SIGTERM, EVFILT_SIGNAL, EV_ADD, 0, 0, 0); r = kevent(kq, &kev, 1, NULL, 0, NULL); assert(r != -1); - signal(SIGTERM, SIG_IGN); + signal(SIGTERM, dummy_sig); while ((ch = getopt(argc, argv, "gvxirdDqn?")) != -1) { switch (ch) { -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070914/8c86a659/attachment.html From source_changes at macosforge.org Fri Sep 14 13:25:43 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:53 2007 Subject: [launchd-changes] [23388] trunk/launchd/src Message-ID: <20070914202543.DB7367B14E3@cvs.opensource.apple.com> Revision: 23388 http://trac.macosforge.org/projects/launchd/changeset/23388 Author: zarzycki@apple.com Date: 2007-09-14 13:25:43 -0700 (Fri, 14 Sep 2007) Log Message: ----------- We need to finish building launchd with -Wshorten-64-to-32 someday... Modified Paths: -------------- trunk/launchd/src/launchctl.c trunk/launchd/src/launchd_core_logic.c trunk/launchd/src/launchproxy.c Modified: trunk/launchd/src/launchctl.c =================================================================== --- trunk/launchd/src/launchctl.c 2007-09-14 18:45:29 UTC (rev 23387) +++ trunk/launchd/src/launchctl.c 2007-09-14 20:25:43 UTC (rev 23388) @@ -3054,8 +3054,8 @@ } if (fstat(fd, &sb) != -1) { - if ((junkbuf = malloc(sb.st_size)) != NULL) { - assumes(read(fd, junkbuf, sb.st_size) == sb.st_size); + if ((sb.st_size < 10*1024*1024) && (junkbuf = malloc((size_t)sb.st_size)) != NULL) { + assumes(read(fd, junkbuf, (size_t)sb.st_size) == (ssize_t)sb.st_size); free(junkbuf); } } Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2007-09-14 18:45:29 UTC (rev 23387) +++ trunk/launchd/src/launchd_core_logic.c 2007-09-14 20:25:43 UTC (rev 23388) @@ -2343,7 +2343,7 @@ td /= NSEC_PER_SEC; if (j->start_time && (td < j->min_run_time) && !j->legacy_mach_job && !j->inetcompat) { - time_t respawn_delta = j->min_run_time - td; + time_t respawn_delta = j->min_run_time - (uint32_t)td; /* * We technically should ref-count throttled jobs to prevent idle exit, @@ -5898,7 +5898,7 @@ job_assumes(j, obj_at_idx = launch_data_array_get_index(out_obj_array, l2l_i)); job_assumes(j, tmp = launch_data_dict_lookup(obj_at_idx, TAKE_SUBSET_PID)); - target_pid = launch_data_get_integer(tmp); + target_pid = (pid_t)launch_data_get_integer(tmp); job_assumes(j, tmp = launch_data_dict_lookup(obj_at_idx, TAKE_SUBSET_PERPID)); serv_perpid = launch_data_get_bool(tmp); job_assumes(j, tmp = launch_data_dict_lookup(obj_at_idx, TAKE_SUBSET_NAME)); Modified: trunk/launchd/src/launchproxy.c =================================================================== --- trunk/launchd/src/launchproxy.c 2007-09-14 18:45:29 UTC (rev 23387) +++ trunk/launchd/src/launchproxy.c 2007-09-14 20:25:43 UTC (rev 23388) @@ -108,7 +108,7 @@ tmp = launch_data_dict_lookup(resp, LAUNCH_JOBKEY_TIMEOUT); if (tmp) - timeout.tv_sec = launch_data_get_integer(tmp); + timeout.tv_sec = (int)launch_data_get_integer(tmp); tmp = launch_data_dict_lookup(resp, LAUNCH_JOBKEY_PROGRAM); if (tmp) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070914/32308168/attachment.html From source_changes at macosforge.org Fri Sep 14 13:59:58 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:53 2007 Subject: [launchd-changes] [23389] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070914205958.8EC9A7B15FE@cvs.opensource.apple.com> Revision: 23389 http://trac.macosforge.org/projects/launchd/changeset/23389 Author: zarzycki@apple.com Date: 2007-09-14 13:59:58 -0700 (Fri, 14 Sep 2007) Log Message: ----------- Better bounds checking. 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-09-14 20:25:43 UTC (rev 23388) +++ trunk/launchd/src/launchd_core_logic.c 2007-09-14 20:59:58 UTC (rev 23389) @@ -351,7 +351,7 @@ uint64_t sent_sigterm_time; uint64_t start_time; uint32_t min_run_time; - unsigned int start_interval; + uint32_t start_interval; 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, start_pending:1; @@ -1418,7 +1418,9 @@ case 'E': if (strcasecmp(key, LAUNCH_JOBKEY_EXITTIMEOUT) == 0) { if (value < 0) { - job_log(j, LOG_WARNING, "Exit timeout less zero. Ignoring."); + job_log(j, LOG_WARNING, "%s less than zero. Ignoring.", LAUNCH_JOBKEY_EXITTIMEOUT); + } else if (value > UINT32_MAX) { + job_log(j, LOG_WARNING, "%s is too large. Ignoring.", LAUNCH_JOBKEY_EXITTIMEOUT); } else { j->exit_timeout = value; } @@ -1434,14 +1436,18 @@ case 't': case 'T': if (strcasecmp(key, LAUNCH_JOBKEY_TIMEOUT) == 0) { - if (value <= 0) { - job_log(j, LOG_WARNING, "Timeout less than or equal to zero. Ignoring."); + if (value < 0) { + job_log(j, LOG_WARNING, "%s less than zero. Ignoring.", LAUNCH_JOBKEY_TIMEOUT); + } else if (value > UINT32_MAX) { + job_log(j, LOG_WARNING, "%s is too large. Ignoring.", LAUNCH_JOBKEY_TIMEOUT); } else { j->timeout = value; } } else if (strcasecmp(key, LAUNCH_JOBKEY_THROTTLEINTERVAL) == 0) { if (value < 0) { job_log(j, LOG_WARNING, "%s less than zero. Ignoring.", LAUNCH_JOBKEY_THROTTLEINTERVAL); + } else if (value > UINT32_MAX) { + job_log(j, LOG_WARNING, "%s is too large. Ignoring.", LAUNCH_JOBKEY_THROTTLEINTERVAL); } else { j->min_run_time = value; } @@ -1458,14 +1464,15 @@ case 'S': if (strcasecmp(key, LAUNCH_JOBKEY_STARTINTERVAL) == 0) { if (value <= 0) { - job_log(j, LOG_WARNING, "StartInterval is not greater than zero, ignoring"); + job_log(j, LOG_WARNING, "%s is not greater than zero. Ignoring.", LAUNCH_JOBKEY_STARTINTERVAL); + } else if (value > UINT32_MAX) { + job_log(j, LOG_WARNING, "%s is too large. Ignoring.", LAUNCH_JOBKEY_STARTINTERVAL); } else { runtime_add_ref(); j->start_interval = value; + + job_assumes(j, kevent_mod((uintptr_t)&j->start_interval, EVFILT_TIMER, EV_ADD, NOTE_SECONDS, value, j) != -1); } - if (-1 == kevent_mod((uintptr_t)&j->start_interval, EVFILT_TIMER, EV_ADD, NOTE_SECONDS, value, j)) { - job_log_error(j, LOG_ERR, "adding kevent timer"); - } } else if (strcasecmp(key, LAUNCH_JOBKEY_SANDBOXFLAGS) == 0) { j->seatbelt_flags = value; } @@ -5192,7 +5199,9 @@ j->ondemand = !inval; break; case VPROC_GSK_START_INTERVAL: - if ((unsigned int)inval > 0) { + if ((uint64_t)inval > UINT32_MAX) { + kr = 1; + } else if (inval) { if (j->start_interval == 0) { runtime_add_ref(); } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070914/6e56e6db/attachment.html From source_changes at macosforge.org Fri Sep 14 14:02:22 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:53 2007 Subject: [launchd-changes] [23390] tags/launchd-245/ Message-ID: <20070914210222.38DFD7B160B@cvs.opensource.apple.com> Revision: 23390 http://trac.macosforge.org/projects/launchd/changeset/23390 Author: zarzycki@apple.com Date: 2007-09-14 14:02:21 -0700 (Fri, 14 Sep 2007) Log Message: ----------- "Tagging launchd-245 from https://svn.macosforge.org/repository/launchd/trunk" Added Paths: ----------- tags/launchd-245/ Copied: tags/launchd-245 (from rev 23389, trunk) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070914/f4fd3a67/attachment.html From source_changes at macosforge.org Fri Sep 14 17:22:39 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:53 2007 Subject: [launchd-changes] [23391] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070915002239.739327B1BBC@cvs.opensource.apple.com> Revision: 23391 http://trac.macosforge.org/projects/launchd/changeset/23391 Author: zarzycki@apple.com Date: 2007-09-14 17:22:39 -0700 (Fri, 14 Sep 2007) Log Message: ----------- Survive PID death during session migration 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-09-14 21:02:21 UTC (rev 23390) +++ trunk/launchd/src/launchd_core_logic.c 2007-09-15 00:22:39 UTC (rev 23391) @@ -5915,9 +5915,10 @@ j_for_service = jobmgr_find_by_pid(jmr, target_pid, true); - if (!jobmgr_assumes(jmr, j_for_service != NULL)) { - kr = BOOTSTRAP_NO_MEMORY; - goto out; + if (!j_for_service) { + /* The PID probably exited */ + job_assumes(j, launchd_mport_deallocate(l2l_ports[l2l_i]) == KERN_SUCCESS); + continue; } if ((ms = machservice_new(j_for_service, serv_name, &l2l_ports[l2l_i], serv_perpid))) { -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070914/493d5627/attachment.html From source_changes at macosforge.org Sun Sep 16 10:37:14 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:53 2007 Subject: [launchd-changes] [23392] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070916173714.ECFA97C3E1C@cvs.opensource.apple.com> Revision: 23392 http://trac.macosforge.org/projects/launchd/changeset/23392 Author: zarzycki@apple.com Date: 2007-09-16 10:37:14 -0700 (Sun, 16 Sep 2007) Log Message: ----------- This happens enought that we shouldn't log it as a Bug any more... 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-09-15 00:22:39 UTC (rev 23391) +++ trunk/launchd/src/launchd_core_logic.c 2007-09-16 17:37:14 UTC (rev 23392) @@ -1007,7 +1007,8 @@ return NULL; } - if (!jobmgr_assumes(jm, len == sizeof(kp))) { + if (len != sizeof(kp)) { + jobmgr_log(jm, LOG_DEBUG, "Tried to create an anonymous job for nonexistent PID: %u", anonpid); return NULL; } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070916/f0306c80/attachment.html From source_changes at macosforge.org Sun Sep 16 10:37:44 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:53 2007 Subject: [launchd-changes] [23393] tags/launchd-246/ Message-ID: <20070916173744.86E5D7C3E2C@cvs.opensource.apple.com> Revision: 23393 http://trac.macosforge.org/projects/launchd/changeset/23393 Author: zarzycki@apple.com Date: 2007-09-16 10:37:44 -0700 (Sun, 16 Sep 2007) Log Message: ----------- "Tagging launchd-246 from https://svn.macosforge.org/repository/launchd/trunk" Added Paths: ----------- tags/launchd-246/ Copied: tags/launchd-246 (from rev 23392, trunk) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070916/33ccd386/attachment.html From source_changes at macosforge.org Mon Sep 17 10:27:39 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:53 2007 Subject: [launchd-changes] [23394] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070917172739.6F5B07C6CD0@cvs.opensource.apple.com> Revision: 23394 http://trac.macosforge.org/projects/launchd/changeset/23394 Author: zarzycki@apple.com Date: 2007-09-17 10:27:38 -0700 (Mon, 17 Sep 2007) Log Message: ----------- Bug: launchd_core_logic.c:523 (23327):1: kill(j->p, SIGTERM) != -1 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-09-16 17:37:44 UTC (rev 23393) +++ trunk/launchd/src/launchd_core_logic.c 2007-09-17 17:27:38 UTC (rev 23394) @@ -523,7 +523,7 @@ return; } - job_assumes(j, kill(j->p, SIGTERM) != -1); + job_assumes(j, killpg(j->p, SIGTERM) != -1); j->sent_sigterm_time = mach_absolute_time(); if (j->exit_timeout) { @@ -2147,7 +2147,7 @@ return; } - job_assumes(j, kill(j->p, SIGKILL) != -1); + job_assumes(j, killpg(j->p, SIGKILL) != -1); j->sent_sigkill = true; @@ -2831,7 +2831,11 @@ setenv(ei->key, ei->value, 1); } - job_assumes(j, setsid() != -1); + if (j->per_user) { + job_assumes(j, setsid() != -1); + } else { + job_assumes(j, setpgid(0, 0) != -1); + } } void @@ -3319,7 +3323,7 @@ time_t now = time(NULL); if (ci && (ci->when_next < now)) { - jobmgr_assumes(root_jobmgr, kill(getpid(), SIGUSR1) != -1); + jobmgr_assumes(root_jobmgr, raise(SIGUSR1) != -1); } } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070917/841d809a/attachment.html From source_changes at macosforge.org Mon Sep 17 12:41:22 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:53 2007 Subject: [launchd-changes] [23395] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070917194122.BB3E97C6F8E@cvs.opensource.apple.com> Revision: 23395 http://trac.macosforge.org/projects/launchd/changeset/23395 Author: zarzycki@apple.com Date: 2007-09-17 12:41:22 -0700 (Mon, 17 Sep 2007) Log Message: ----------- More fallout from: Bug: launchd_core_logic.c:523 (23327):1: kill(j->p, SIGTERM) != -1 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-09-17 17:27:38 UTC (rev 23394) +++ trunk/launchd/src/launchd_core_logic.c 2007-09-17 19:41:22 UTC (rev 23395) @@ -523,7 +523,7 @@ return; } - job_assumes(j, killpg(j->p, SIGTERM) != -1); + job_assumes(j, kill(j->p, SIGTERM) != -1); j->sent_sigterm_time = mach_absolute_time(); if (j->exit_timeout) { @@ -1955,12 +1955,24 @@ if (j->anonymous) { status = 0; memset(&ru, 0, sizeof(ru)); - } else if (!job_assumes(j, wait4(j->p, &status, 0, &ru) != -1)) { - job_log(j, LOG_NOTICE, "Working around 5020256. Assuming the job crashed."); + } else { + /* + * The job is dead. While the PID/PGID is still known to be + * valid, try to kill abandoned descendant processes. + * + * We'd use job_assumes(), but POSIX defines consistency over + * correctness, and consequently kill/killpg now returns EPERM + * instead of ESRCH. As luck would have it, ESRCH is the only + * error we can ignore. + */ + killpg(j->p, SIGKILL); - status = W_EXITCODE(0, SIGSEGV); + if (!job_assumes(j, wait4(j->p, &status, 0, &ru) != -1)) { + job_log(j, LOG_NOTICE, "Working around 5020256. Assuming the job crashed."); - memset(&ru, 0, sizeof(ru)); + status = W_EXITCODE(0, SIGSEGV); + memset(&ru, 0, sizeof(ru)); + } } if (j->exit_timeout) { @@ -2147,7 +2159,7 @@ return; } - job_assumes(j, killpg(j->p, SIGKILL) != -1); + job_assumes(j, kill(j->p, SIGKILL) != -1); j->sent_sigkill = true; -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070917/bc6e77f5/attachment.html From source_changes at macosforge.org Mon Sep 17 13:00:36 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:53 2007 Subject: [launchd-changes] [23396] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070917200036.C01327C6FF2@cvs.opensource.apple.com> Revision: 23396 http://trac.macosforge.org/projects/launchd/changeset/23396 Author: zarzycki@apple.com Date: 2007-09-17 13:00:36 -0700 (Mon, 17 Sep 2007) Log Message: ----------- More documentation. 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-09-17 19:41:22 UTC (rev 23395) +++ trunk/launchd/src/launchd_core_logic.c 2007-09-17 20:00:36 UTC (rev 23396) @@ -1967,6 +1967,19 @@ */ killpg(j->p, SIGKILL); + /* + * 5020256 + * + * The current implementation of ptrace() causes the traced process to + * be abducted away from the true parent and adopted by the tracer. + * + * Once the tracing process relinquishes control, the kernel then + * restores the true parent/child relationship. + * + * Unfortunately, the wait*() family of APIs is unaware of the temporarily + * data structures changes, and they return an error if reality hasn't + * been restored by the time they are called. + */ if (!job_assumes(j, wait4(j->p, &status, 0, &ru) != -1)) { job_log(j, LOG_NOTICE, "Working around 5020256. Assuming the job crashed."); -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070917/c658a670/attachment.html From source_changes at macosforge.org Mon Sep 17 14:58:35 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:54 2007 Subject: [launchd-changes] [23397] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070917215835.83B977C72D7@cvs.opensource.apple.com> Revision: 23397 http://trac.macosforge.org/projects/launchd/changeset/23397 Author: zarzycki@apple.com Date: 2007-09-17 14:58:35 -0700 (Mon, 17 Sep 2007) Log Message: ----------- The first per user launchd may be on behalf of a daemon and not a "real" user. 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-09-17 20:00:36 UTC (rev 23396) +++ trunk/launchd/src/launchd_core_logic.c 2007-09-17 21:58:35 UTC (rev 23397) @@ -452,6 +452,7 @@ static size_t total_children; static mach_port_t the_exception_server; static bool did_first_per_user_launchd_BootCache_hack; +#define JOB_BOOTCACHE_HACK_CHECK(j) (j->per_user && !did_first_per_user_launchd_BootCache_hack && (j->mach_uid >= 500) && (j->mach_uid != (uid_t)-2)) static jobmgr_t background_jobmgr; static job_t workaround_5477111; static mach_timebase_info_data_t tbi; @@ -460,6 +461,7 @@ mach_port_t inherited_bootstrap_port; jobmgr_t root_jobmgr; + void job_ignore(job_t j) { @@ -2450,7 +2452,7 @@ total_children++; LIST_INSERT_HEAD(&j->mgr->active_jobs[ACTIVE_JOB_HASH(c)], j, pid_hash_sle); - if (j->per_user && !did_first_per_user_launchd_BootCache_hack) { + if (JOB_BOOTCACHE_HACK_CHECK(j)) { did_first_per_user_launchd_BootCache_hack = true; } @@ -2512,7 +2514,7 @@ size_t binpref_out_cnt = 0; int i; - if (j->per_user && !did_first_per_user_launchd_BootCache_hack) { + if (JOB_BOOTCACHE_HACK_CHECK(j)) { do_first_per_user_launchd_hack(); } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070917/b0fdfab6/attachment.html From source_changes at macosforge.org Mon Sep 17 14:58:49 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:54 2007 Subject: [launchd-changes] [23398] tags/launchd-247/ Message-ID: <20070917215849.97FB77C72DB@cvs.opensource.apple.com> Revision: 23398 http://trac.macosforge.org/projects/launchd/changeset/23398 Author: zarzycki@apple.com Date: 2007-09-17 14:58:49 -0700 (Mon, 17 Sep 2007) Log Message: ----------- "Tagging launchd-247 from https://svn.macosforge.org/repository/launchd/trunk" Added Paths: ----------- tags/launchd-247/ Copied: tags/launchd-247 (from rev 23397, trunk) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070917/647330d9/attachment.html From source_changes at macosforge.org Mon Sep 17 18:32:13 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:54 2007 Subject: [launchd-changes] [23399] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070918013213.697D47C76AC@cvs.opensource.apple.com> Revision: 23399 http://trac.macosforge.org/projects/launchd/changeset/23399 Author: zarzycki@apple.com Date: 2007-09-17 18:32:10 -0700 (Mon, 17 Sep 2007) Log Message: ----------- Regression due to 5475980 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-09-17 21:58:49 UTC (rev 23398) +++ trunk/launchd/src/launchd_core_logic.c 2007-09-18 01:32:10 UTC (rev 23399) @@ -714,6 +714,7 @@ } if (jm->parentmgr) { + runtime_del_ref(); SLIST_REMOVE(&jm->parentmgr->submgrs, jm, jobmgr_s, sle); } else if (getpid() == 1) { jobmgr_log(jm, LOG_DEBUG, "About to call: reboot(%s)", reboot_flags_to_C_names(jm->reboot_flags)); @@ -4228,6 +4229,10 @@ jobmgr_assumes(jmr, job_dispatch(bootstrapper, true) != NULL); } + if (jmr->parentmgr) { + runtime_add_ref(); + } + return jmr; out_bad: -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070917/e644b167/attachment.html From source_changes at macosforge.org Mon Sep 17 18:37:38 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:54 2007 Subject: [launchd-changes] [23400] trunk/launchd/src/launchctl.c Message-ID: <20070918013738.6CE777C76C2@cvs.opensource.apple.com> Revision: 23400 http://trac.macosforge.org/projects/launchd/changeset/23400 Author: zarzycki@apple.com Date: 2007-09-17 18:37:37 -0700 (Mon, 17 Sep 2007) Log Message: ----------- This just disables source for the embedded world. Modified Paths: -------------- trunk/launchd/src/launchctl.c Modified: trunk/launchd/src/launchctl.c =================================================================== --- trunk/launchd/src/launchctl.c 2007-09-18 01:32:10 UTC (rev 23399) +++ trunk/launchd/src/launchctl.c 2007-09-18 01:37:37 UTC (rev 23400) @@ -29,8 +29,11 @@ #include #include +#include +#if !TARGET_OS_EMBEDDED #include #include +#endif #include #include #include @@ -1592,25 +1595,27 @@ load_launchd_items[4] = "system"; } - if (strcasecmp(session_type, "Background") == 0 || strcasecmp(session_type, "LoginWindow") == 0) { + if (strcasecmp(session_type, VPROCMGR_SESSION_BACKGROUND) == 0 || strcasecmp(session_type, VPROCMGR_SESSION_LOGINWINDOW) == 0) { load_launchd_items[4] = "system"; if (!is_safeboot()) { load_launchd_items[5] = "-D"; load_launchd_items[6] = "local"; the_argc += 2; } - if (strcasecmp(session_type, "LoginWindow") == 0) { + if (strcasecmp(session_type, VPROCMGR_SESSION_LOGINWINDOW) == 0) { load_launchd_items[the_argc] = "/etc/mach_init_per_login_session.d"; the_argc += 1; } - } else if (strcasecmp(session_type, "Aqua") == 0) { + } else if (strcasecmp(session_type, VPROCMGR_SESSION_AQUA) == 0) { load_launchd_items[5] = "/etc/mach_init_per_user.d"; the_argc += 1; } - if (strcasecmp(session_type, "Background") == 0) { +#if !TARGET_OS_EMBEDDED + if (strcasecmp(session_type, VPROCMGR_SESSION_BACKGROUND) == 0) { assumes(SessionCreate(sessionKeepCurrentBootstrap, 0) == 0); } +#endif return load_and_unload_cmd(the_argc, load_launchd_items); } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070917/396f523b/attachment.html From source_changes at macosforge.org Mon Sep 17 18:38:21 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:54 2007 Subject: [launchd-changes] [23401] tags/launchd-248/ Message-ID: <20070918013821.D4BE37C76C8@cvs.opensource.apple.com> Revision: 23401 http://trac.macosforge.org/projects/launchd/changeset/23401 Author: zarzycki@apple.com Date: 2007-09-17 18:38:21 -0700 (Mon, 17 Sep 2007) Log Message: ----------- "Tagging launchd-248 from https://svn.macosforge.org/repository/launchd/trunk" Added Paths: ----------- tags/launchd-248/ Copied: tags/launchd-248 (from rev 23400, trunk) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070917/1e7dd1d1/attachment.html From source_changes at macosforge.org Tue Sep 18 07:54:49 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:54 2007 Subject: [launchd-changes] [23402] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070918145449.F23EA7CA18C@cvs.opensource.apple.com> Revision: 23402 http://trac.macosforge.org/projects/launchd/changeset/23402 Author: zarzycki@apple.com Date: 2007-09-18 07:54:49 -0700 (Tue, 18 Sep 2007) Log Message: ----------- Cancelled FUS restart cause pre-login launchd agent race 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-09-18 01:38:21 UTC (rev 23401) +++ trunk/launchd/src/launchd_core_logic.c 2007-09-18 14:54:49 UTC (rev 23402) @@ -1778,6 +1778,8 @@ LIST_FOREACH(ji, &label_hash[hash_label(label)], label_hash_sle) { if (ji->removal_pending) { continue; /* 5351245 */ + } else if (ji->mgr->shutting_down) { + continue; /* 5488633 */ } if (strcmp(ji->label, label) == 0) { -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070918/0b48cdc7/attachment.html From source_changes at macosforge.org Tue Sep 18 08:01:55 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:54 2007 Subject: [launchd-changes] [23403] trunk/launchd/src/StartupItems.c Message-ID: <20070918150155.3AA6A7CA1BB@cvs.opensource.apple.com> Revision: 23403 http://trac.macosforge.org/projects/launchd/changeset/23403 Author: zarzycki@apple.com Date: 2007-09-18 08:01:54 -0700 (Tue, 18 Sep 2007) Log Message: ----------- Leopard 9A527: "Startup Items folder does not have proper security settings" Modified Paths: -------------- trunk/launchd/src/StartupItems.c Modified: trunk/launchd/src/StartupItems.c =================================================================== --- trunk/launchd/src/StartupItems.c 2007-09-18 14:54:49 UTC (rev 23402) +++ trunk/launchd/src/StartupItems.c 2007-09-18 15:01:54 UTC (rev 23403) @@ -285,6 +285,12 @@ strcpy(aPath + strlen(aPath), kStartupItemsPath); ++aDomainIndex; + /* 5485016 + * + * Just in case... + */ + mkdir(aPath, S_IRWXU|S_IRWXG|S_IROTH|S_IXOTH); + if (!StartupItemSecurityCheck(aPath)) continue; -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070918/51a0fed8/attachment.html From source_changes at macosforge.org Tue Sep 18 09:37:12 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:54 2007 Subject: [launchd-changes] [23404] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070918163712.B246C7CA39D@cvs.opensource.apple.com> Revision: 23404 http://trac.macosforge.org/projects/launchd/changeset/23404 Author: zarzycki@apple.com Date: 2007-09-18 09:37:12 -0700 (Tue, 18 Sep 2007) Log Message: ----------- Slightly better logging. 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-09-18 15:01:54 UTC (rev 23403) +++ trunk/launchd/src/launchd_core_logic.c 2007-09-18 16:37:12 UTC (rev 23404) @@ -4093,6 +4093,7 @@ 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; + pid_t pg_i = kp[i].kp_eproc.e_pgid; const char *z = kp[i].kp_proc.p_stat == SZOMB ? "zombie " : ""; const char *n = kp[i].kp_proc.p_comm; @@ -4100,7 +4101,7 @@ continue; } - jobmgr_log(jm, LOG_WARNING, "Stray %sprocess at shutdown: PID %u PPID %u %s", z, p_i, pp_i, n); + jobmgr_log(jm, LOG_WARNING, "Stray %sprocess at shutdown: PID %u PPID %u PGID %u %s", z, p_i, pp_i, pg_i, n); /* * The kernel team requested that launchd not do this for Leopard. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070918/7515d0cb/attachment.html From source_changes at macosforge.org Tue Sep 18 11:28:04 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:54 2007 Subject: [launchd-changes] [23405] trunk/launchd/src/launchproxy.c Message-ID: <20070918182804.B028D7CA6DA@cvs.opensource.apple.com> Revision: 23405 http://trac.macosforge.org/projects/launchd/changeset/23405 Author: zarzycki@apple.com Date: 2007-09-18 11:28:04 -0700 (Tue, 18 Sep 2007) Log Message: ----------- Regression due to 5475980 Modified Paths: -------------- trunk/launchd/src/launchproxy.c Modified: trunk/launchd/src/launchproxy.c =================================================================== --- trunk/launchd/src/launchproxy.c 2007-09-18 16:37:12 UTC (rev 23404) +++ trunk/launchd/src/launchproxy.c 2007-09-18 18:28:04 UTC (rev 23405) @@ -182,6 +182,8 @@ continue; } + setpgid(0, 0); + if ((tmp = launch_data_dict_lookup(resp, LAUNCH_JOBKEY_SESSIONCREATE)) && launch_data_get_bool(tmp)) { if (SessionCreate) { OSStatus scr = SessionCreate(0, 0); -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070918/d0847621/attachment.html From source_changes at macosforge.org Tue Sep 18 12:26:58 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:54 2007 Subject: [launchd-changes] [23406] trunk/launchd/src Message-ID: <20070918192658.D6B957CA8C2@cvs.opensource.apple.com> Revision: 23406 http://trac.macosforge.org/projects/launchd/changeset/23406 Author: zarzycki@apple.com Date: 2007-09-18 12:26:53 -0700 (Tue, 18 Sep 2007) Log Message: ----------- A new job attribute: AbandonProcessGroup 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-09-18 18:28:04 UTC (rev 23405) +++ trunk/launchd/src/launchd.plist.5 2007-09-18 19:26:53 UTC (rev 23406) @@ -278,6 +278,11 @@ This optional key specifies what .Xr nice 3 value should be applied to the daemon. +.It Sy AbandonProcessGroup +When a job dies, +.Nm launchd +kills any remaining processes with the same process group ID as the job. +Setting this key to true disables that behavior. .It Sy HopefullyExitsFirst This optional key causes programs to exit earlier during system shutdown. This key exists because some jobs do more than flush buffers and exit like Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2007-09-18 18:28:04 UTC (rev 23405) +++ trunk/launchd/src/launchd_core_logic.c 2007-09-18 19:26:53 UTC (rev 23406) @@ -359,7 +359,7 @@ 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, wait4pipe_eof:1, sent_sigkill:1, debug_before_kill:1, weird_bootstrap:1, start_on_mount:1, - per_user:1, hopefully_exits_first:1, deny_unknown_mslookups:1, unload_at_mig_return:1; + per_user:1, hopefully_exits_first:1, deny_unknown_mslookups:1, unload_at_mig_return:1, abandon_pg:1; const char label[0]; }; @@ -1223,6 +1223,13 @@ bool found_key = false; switch (key[0]) { + case 'a': + case 'A': + if (strcasecmp(key, LAUNCH_JOBKEY_ABANDONPROCESSGROUP) == 0) { + j->abandon_pg = value; + found_key = true; + } + break; case 'k': case 'K': if (strcasecmp(key, LAUNCH_JOBKEY_KEEPALIVE) == 0) { @@ -1970,7 +1977,9 @@ * instead of ESRCH. As luck would have it, ESRCH is the only * error we can ignore. */ - killpg(j->p, SIGKILL); + if (!j->abandon_pg) { + killpg(j->p, SIGKILL); + } /* * 5020256 Modified: trunk/launchd/src/liblaunch_public.h =================================================================== --- trunk/launchd/src/liblaunch_public.h 2007-09-18 18:28:04 UTC (rev 23405) +++ trunk/launchd/src/liblaunch_public.h 2007-09-18 19:26:53 UTC (rev 23406) @@ -98,6 +98,7 @@ #define LAUNCH_JOBKEY_PID "PID" #define LAUNCH_JOBKEY_THROTTLEINTERVAL "ThrottleInterval" #define LAUNCH_JOBKEY_LAUNCHONLYONCE "LaunchOnlyOnce" +#define LAUNCH_JOBKEY_ABANDONPROCESSGROUP "AbandonProcessGroup" #define LAUNCH_JOBINETDCOMPATIBILITY_WAIT "Wait" -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070918/b91ef1ab/attachment.html From source_changes at macosforge.org Tue Sep 18 12:59:39 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:54 2007 Subject: [launchd-changes] [23407] tags/launchd-249/ Message-ID: <20070918195939.5691C7CA99C@cvs.opensource.apple.com> Revision: 23407 http://trac.macosforge.org/projects/launchd/changeset/23407 Author: zarzycki@apple.com Date: 2007-09-18 12:59:38 -0700 (Tue, 18 Sep 2007) Log Message: ----------- "Tagging launchd-249 from https://svn.macosforge.org/repository/launchd/trunk" Added Paths: ----------- tags/launchd-249/ Copied: tags/launchd-249 (from rev 23406, trunk) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070918/e9844c90/attachment.html From source_changes at macosforge.org Tue Sep 18 18:00:28 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:54 2007 Subject: [launchd-changes] [23408] trunk/launchd/src Message-ID: <20070919010028.D41917CB18E@cvs.opensource.apple.com> Revision: 23408 http://trac.macosforge.org/projects/launchd/changeset/23408 Author: zarzycki@apple.com Date: 2007-09-18 18:00:28 -0700 (Tue, 18 Sep 2007) Log Message: ----------- We need to wrap kill()/killpg() to get ESRCH returned instead of EPERM. EPERM is still returned when appropriate. Modified Paths: -------------- trunk/launchd/src/Makefile.am trunk/launchd/src/Makefile.in trunk/launchd/src/launchd.c trunk/launchd/src/launchd_core_logic.c trunk/launchd/src/launchd_runtime.h Added Paths: ----------- trunk/launchd/src/launchd_runtime_kill.c trunk/launchd/src/launchd_runtime_kill.h Modified: trunk/launchd/src/Makefile.am =================================================================== --- trunk/launchd/src/Makefile.am 2007-09-18 19:59:38 UTC (rev 23407) +++ trunk/launchd/src/Makefile.am 2007-09-19 01:00:28 UTC (rev 23408) @@ -48,7 +48,7 @@ launchd_CFLAGS = -mdynamic-no-pic $(AM_CFLAGS) -Wno-unused-parameter launchd_LDFLAGS = -lbsm -launchd_SOURCES = launchd.c launchd_core_logic.c launchd_unix_ipc.c protocol_vprocServer.c notifyServer.c launchd_internalUser.c launchd_internalServer.c job_replyUser.c launchd_runtime.c +launchd_SOURCES = launchd.c launchd_core_logic.c launchd_unix_ipc.c protocol_vprocServer.c notifyServer.c launchd_internalUser.c launchd_internalServer.c job_replyUser.c launchd_runtime.c launchd_runtime_kill.c launchd_runtime.c:: notifyServer.h launchd_internal.h launchd_core_logic.c:: protocol_vproc.h job_reply.h protocol_vprocServer.h Modified: trunk/launchd/src/Makefile.in =================================================================== --- trunk/launchd/src/Makefile.in 2007-09-18 19:59:38 UTC (rev 23407) +++ trunk/launchd/src/Makefile.in 2007-09-19 01:00:28 UTC (rev 23408) @@ -96,7 +96,7 @@ am__launchd_SOURCES_DIST = launchd.c launchd_core_logic.c \ launchd_unix_ipc.c protocol_vprocServer.c notifyServer.c \ launchd_internalUser.c launchd_internalServer.c \ - job_replyUser.c launchd_runtime.c + job_replyUser.c launchd_runtime.c launchd_runtime_kill.c @LIBS_ONLY_FALSE@am_launchd_OBJECTS = launchd-launchd.$(OBJEXT) \ @LIBS_ONLY_FALSE@ launchd-launchd_core_logic.$(OBJEXT) \ @LIBS_ONLY_FALSE@ launchd-launchd_unix_ipc.$(OBJEXT) \ @@ -105,7 +105,8 @@ @LIBS_ONLY_FALSE@ launchd-launchd_internalUser.$(OBJEXT) \ @LIBS_ONLY_FALSE@ launchd-launchd_internalServer.$(OBJEXT) \ @LIBS_ONLY_FALSE@ launchd-job_replyUser.$(OBJEXT) \ -@LIBS_ONLY_FALSE@ launchd-launchd_runtime.$(OBJEXT) +@LIBS_ONLY_FALSE@ launchd-launchd_runtime.$(OBJEXT) \ +@LIBS_ONLY_FALSE@ launchd-launchd_runtime_kill.$(OBJEXT) launchd_OBJECTS = $(am_launchd_OBJECTS) launchd_LDADD = $(LDADD) launchd_LINK = $(CCLD) $(launchd_CFLAGS) $(CFLAGS) $(launchd_LDFLAGS) \ @@ -252,7 +253,7 @@ @LIBS_ONLY_FALSE@SystemStarter_SOURCES = StartupItems.c IPC.c SystemStarter.c @LIBS_ONLY_FALSE@launchd_CFLAGS = -mdynamic-no-pic $(AM_CFLAGS) -Wno-unused-parameter @LIBS_ONLY_FALSE@launchd_LDFLAGS = -lbsm -@LIBS_ONLY_FALSE@launchd_SOURCES = launchd.c launchd_core_logic.c launchd_unix_ipc.c protocol_vprocServer.c notifyServer.c launchd_internalUser.c launchd_internalServer.c job_replyUser.c launchd_runtime.c +@LIBS_ONLY_FALSE@launchd_SOURCES = launchd.c launchd_core_logic.c launchd_unix_ipc.c protocol_vprocServer.c notifyServer.c launchd_internalUser.c launchd_internalServer.c job_replyUser.c launchd_runtime.c launchd_runtime_kill.c @LIBS_ONLY_FALSE@launchproxy_LDFLAGS = -weak_framework Security @LIBS_ONLY_FALSE@man1_MANS = wait4path.1 launchctl.1 @LIBS_ONLY_FALSE@man5_MANS = launchd.plist.5 launchd.conf.5 @@ -420,6 +421,7 @@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/launchd-launchd_internalServer.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/launchd-launchd_internalUser.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/launchd-launchd_runtime.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/launchd-launchd_runtime_kill.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/launchd-launchd_unix_ipc.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/launchd-notifyServer.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/launchd-protocol_vprocServer.Po@am__quote@ @@ -771,6 +773,20 @@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='launchd_runtime.c' object='launchd-launchd_runtime.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(launchd_CFLAGS) $(CFLAGS) -c -o launchd-launchd_runtime.obj `if test -f 'launchd_runtime.c'; then $(CYGPATH_W) 'launchd_runtime.c'; else $(CYGPATH_W) '$(srcdir)/launchd_runtime.c'; fi` + +launchd-launchd_runtime_kill.o: launchd_runtime_kill.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(launchd_CFLAGS) $(CFLAGS) -MT launchd-launchd_runtime_kill.o -MD -MP -MF $(DEPDIR)/launchd-launchd_runtime_kill.Tpo -c -o launchd-launchd_runtime_kill.o `test -f 'launchd_runtime_kill.c' || echo '$(srcdir)/'`launchd_runtime_kill.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/launchd-launchd_runtime_kill.Tpo $(DEPDIR)/launchd-launchd_runtime_kill.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='launchd_runtime_kill.c' object='launchd-launchd_runtime_kill.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(launchd_CFLAGS) $(CFLAGS) -c -o launchd-launchd_runtime_kill.o `test -f 'launchd_runtime_kill.c' || echo '$(srcdir)/'`launchd_runtime_kill.c + +launchd-launchd_runtime_kill.obj: launchd_runtime_kill.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(launchd_CFLAGS) $(CFLAGS) -MT launchd-launchd_runtime_kill.obj -MD -MP -MF $(DEPDIR)/launchd-launchd_runtime_kill.Tpo -c -o launchd-launchd_runtime_kill.obj `if test -f 'launchd_runtime_kill.c'; then $(CYGPATH_W) 'launchd_runtime_kill.c'; else $(CYGPATH_W) '$(srcdir)/launchd_runtime_kill.c'; fi` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/launchd-launchd_runtime_kill.Tpo $(DEPDIR)/launchd-launchd_runtime_kill.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='launchd_runtime_kill.c' object='launchd-launchd_runtime_kill.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(launchd_CFLAGS) $(CFLAGS) -c -o launchd-launchd_runtime_kill.obj `if test -f 'launchd_runtime_kill.c'; then $(CYGPATH_W) 'launchd_runtime_kill.c'; else $(CYGPATH_W) '$(srcdir)/launchd_runtime_kill.c'; fi` install-man1: $(man1_MANS) $(man_MANS) @$(NORMAL_INSTALL) test -z "$(man1dir)" || $(MKDIR_P) "$(DESTDIR)$(man1dir)" Modified: trunk/launchd/src/launchd.c =================================================================== --- trunk/launchd/src/launchd.c 2007-09-18 19:59:38 UTC (rev 23407) +++ trunk/launchd/src/launchd.c 2007-09-19 01:00:28 UTC (rev 23408) @@ -277,7 +277,7 @@ sleep(3); - kill(-1, SIGKILL); + runtime_kill(-1, SIGKILL); } void Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2007-09-18 19:59:38 UTC (rev 23407) +++ trunk/launchd/src/launchd_core_logic.c 2007-09-19 01:00:28 UTC (rev 23408) @@ -525,7 +525,7 @@ return; } - job_assumes(j, kill(j->p, SIGTERM) != -1); + job_assumes(j, runtime_kill(j->p, SIGTERM) != -1); j->sent_sigterm_time = mach_absolute_time(); if (j->exit_timeout) { @@ -1971,14 +1971,9 @@ /* * The job is dead. While the PID/PGID is still known to be * valid, try to kill abandoned descendant processes. - * - * We'd use job_assumes(), but POSIX defines consistency over - * correctness, and consequently kill/killpg now returns EPERM - * instead of ESRCH. As luck would have it, ESRCH is the only - * error we can ignore. */ if (!j->abandon_pg) { - killpg(j->p, SIGKILL); + job_assumes(j, runtime_killpg(j->p, SIGKILL) != -1 || errno == ESRCH); } /* @@ -2186,7 +2181,7 @@ return; } - job_assumes(j, kill(j->p, SIGKILL) != -1); + job_assumes(j, runtime_kill(j->p, SIGKILL) != -1); j->sent_sigkill = true; @@ -2690,7 +2685,7 @@ /* Temporarily disabled due to 5423935 and 4946119. */ #if 0 /* Ask the accountless process to exit. */ - job_assumes(j, kill(i_pid, SIGTERM) != -1); + job_assumes(j, runtime_kill(i_pid, SIGTERM) != -1); #endif } @@ -4114,7 +4109,7 @@ /* * The kernel team requested that launchd not do this for Leopard. - * jobmgr_assumes(jm, kill(p_i, SIGKILL) != -1); + * jobmgr_assumes(jm, runtime_kill(p_i, SIGKILL) != -1); */ } @@ -5026,7 +5021,7 @@ return 0; } } else if (otherj->p) { - job_assumes(j, kill(otherj->p, sig) != -1); + job_assumes(j, runtime_kill(otherj->p, sig) != -1); } return 0; Modified: trunk/launchd/src/launchd_runtime.h =================================================================== --- trunk/launchd/src/launchd_runtime.h 2007-09-18 19:59:38 UTC (rev 23407) +++ trunk/launchd/src/launchd_runtime.h 2007-09-19 01:00:28 UTC (rev 23408) @@ -26,6 +26,8 @@ #include #include +#include "launchd_runtime_kill.h" + struct ldcred { uid_t euid; uid_t uid; Added: trunk/launchd/src/launchd_runtime_kill.c =================================================================== --- trunk/launchd/src/launchd_runtime_kill.c (rev 0) +++ trunk/launchd/src/launchd_runtime_kill.c 2007-09-19 01:00:28 UTC (rev 23408) @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2007 Apple Inc. All rights reserved. + * + * @APPLE_APACHE_LICENSE_HEADER_START@ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * @APPLE_APACHE_LICENSE_HEADER_END@ + */ + +#define _NONSTD_SOURCE 1 +#include + +#include "launchd_runtime_kill.h" + +/* + * POSIX defines consistency over correctness, and consequently kill/killpg now + * returns EPERM instead of ESRCH. + * + * I've filed 5487498 to get a non-portable kill() variant, but for now, + * defining _NONSTD_SOURCE gets us the old behavior. + */ + +int +runtime_kill(pid_t pid, int sig) +{ + return kill(pid, sig); +} + +int +runtime_killpg(pid_t pgrp, int sig) +{ + return killpg(pgrp, sig); +} Added: trunk/launchd/src/launchd_runtime_kill.h =================================================================== --- trunk/launchd/src/launchd_runtime_kill.h (rev 0) +++ trunk/launchd/src/launchd_runtime_kill.h 2007-09-19 01:00:28 UTC (rev 23408) @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2007 Apple Inc. All rights reserved. + * + * @APPLE_APACHE_LICENSE_HEADER_START@ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * @APPLE_APACHE_LICENSE_HEADER_END@ + */ +#ifndef __LAUNCHD_RUNTIME_KILL_H__ +#define __LAUNCHD_RUNTIME_KILL_H__ + +#include + +int runtime_kill(pid_t pid, int sig); +int runtime_killpg(pid_t pgrp, int sig); + +#endif -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070918/74511c4b/attachment.html From source_changes at macosforge.org Wed Sep 19 09:05:31 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:54 2007 Subject: [launchd-changes] [23409] trunk/launchd/src Message-ID: <20070919160531.7D7EF7CBE7E@cvs.opensource.apple.com> Revision: 23409 http://trac.macosforge.org/projects/launchd/changeset/23409 Author: zarzycki@apple.com Date: 2007-09-19 09:05:30 -0700 (Wed, 19 Sep 2007) Log Message: ----------- More shutdown debug logging. Modified Paths: -------------- trunk/launchd/src/launchd_core_logic.c trunk/launchd/src/launchd_core_logic.h trunk/launchd/src/launchd_runtime.c Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2007-09-19 01:00:28 UTC (rev 23408) +++ trunk/launchd/src/launchd_core_logic.c 2007-09-19 16:05:30 UTC (rev 23409) @@ -381,6 +381,7 @@ static void job_import_array(job_t j, const char *key, launch_data_t value); static void job_import_opaque(job_t j, const char *key, launch_data_t value); static bool job_set_global_on_demand(job_t j, bool val); +static const char *job_active(job_t j); static void job_watch(job_t j); static void job_ignore(job_t j); static void job_reap(job_t j); @@ -532,6 +533,8 @@ job_assumes(j, kevent_mod((uintptr_t)&j->exit_timeout, EVFILT_TIMER, EV_ADD|EV_ONESHOT, NOTE_SECONDS, j->exit_timeout, j) != -1); } + + job_log(j, LOG_DEBUG, "Sent SIGTERM signal."); } launch_data_t @@ -645,10 +648,31 @@ } static void +jobmgr_log_active_jobs(jobmgr_t jm) +{ + const char *why_active; + jobmgr_t jmi; + job_t ji; + + SLIST_FOREACH(jmi, &jm->submgrs, sle) { + jobmgr_log_active_jobs(jmi); + } + + LIST_FOREACH(ji, &jm->jobs, sle) { + why_active = job_active(ji); + + job_log(ji, LOG_DEBUG, "%s", why_active ? why_active : "Inactive"); + } + +} + +static void still_alive_with_check(void) { jobmgr_log(root_jobmgr, LOG_NOTICE, "Still alive with %lu children.", total_children); + jobmgr_log_active_jobs(root_jobmgr); + runtime_closelog(); /* hack to flush logs */ } @@ -675,7 +699,7 @@ } if (debug_shutdown_hangs && jm->parentmgr == NULL && getpid() == 1) { - runtime_set_timeout(still_alive_with_check, 3000); + runtime_set_timeout(still_alive_with_check, 5); } return jobmgr_do_garbage_collection(jm); @@ -2187,6 +2211,8 @@ job_assumes(j, kevent_mod((uintptr_t)&j->exit_timeout, EVFILT_TIMER, EV_ADD, NOTE_SECONDS, LAUNCHD_SIGKILL_TIMER, j) != -1); + + job_log(j, LOG_DEBUG, "Sent SIGKILL signal."); } void @@ -3773,30 +3799,30 @@ } } -bool +const char * job_active(job_t j) { struct machservice *ms; if (j->wait4pipe_eof && j->log_redirect_fd) { - return true; + return "Standard out/error is still valid"; } if (j->p) { - return true; + return "PID is still valid"; } if (j->priv_port_has_senders) { - return true; + return "Privileged Port still has outstanding senders"; } SLIST_FOREACH(ms, &j->machservices, sle) { if (ms->recv && ms->isActive) { - return true; + return "Mach service is still active"; } } - return false; + return NULL; } void Modified: trunk/launchd/src/launchd_core_logic.h =================================================================== --- trunk/launchd/src/launchd_core_logic.h 2007-09-19 01:00:28 UTC (rev 23408) +++ trunk/launchd/src/launchd_core_logic.h 2007-09-19 16:05:30 UTC (rev 23409) @@ -40,7 +40,6 @@ job_t job_find(const char *label); job_t job_find_by_service_port(mach_port_t p); bool job_ack_port_destruction(mach_port_t p); -bool job_active(job_t j); bool job_is_anonymous(job_t j); launch_data_t job_export(job_t j); void job_stop(job_t j); Modified: trunk/launchd/src/launchd_runtime.c =================================================================== --- trunk/launchd/src/launchd_runtime.c 2007-09-19 01:00:28 UTC (rev 23408) +++ trunk/launchd/src/launchd_runtime.c 2007-09-19 16:05:30 UTC (rev 23409) @@ -90,8 +90,8 @@ static mach_msg_size_t max_msg_size; static mig_callback *mig_cb_table; static size_t mig_cb_table_sz; -static timeout_callback runtime_idle_callback = launchd_shutdown; -static mach_msg_timeout_t runtime_idle_timeout = RUNTIME_ADVISABLE_IDLE_TIMEOUT * 1000; +static timeout_callback runtime_idle_callback; +static mach_msg_timeout_t runtime_idle_timeout; static audit_token_t *au_tok; static size_t runtime_busy_cnt; @@ -912,11 +912,11 @@ } } - if ((tmp_options & MACH_RCV_MSG) && runtime_idle_callback && (runtime_busy_cnt == 0)) { + if ((tmp_options & MACH_RCV_MSG) && (runtime_idle_callback || (runtime_busy_cnt == 0))) { tmp_options |= MACH_RCV_TIMEOUT; if (!(tmp_options & MACH_SEND_TIMEOUT)) { - to = runtime_idle_timeout; + to = runtime_busy_cnt ? runtime_idle_timeout : (RUNTIME_ADVISABLE_IDLE_TIMEOUT * 1000); } } @@ -935,7 +935,11 @@ continue; } else if (mr == MACH_RCV_TIMED_OUT) { if (to != MACH_MSG_TIMEOUT_NONE) { - runtime_idle_callback(); + if (runtime_busy_cnt == 0) { + launchd_shutdown(); + } else if (runtime_idle_callback) { + runtime_idle_callback(); + } } continue; } else if (!launchd_assumes(mr == MACH_MSG_SUCCESS)) { -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070919/0933e1da/attachment.html From source_changes at macosforge.org Wed Sep 19 09:14:50 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:54 2007 Subject: [launchd-changes] [23410] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070919161450.D443E7CBEB0@cvs.opensource.apple.com> Revision: 23410 http://trac.macosforge.org/projects/launchd/changeset/23410 Author: zarzycki@apple.com Date: 2007-09-19 09:14:50 -0700 (Wed, 19 Sep 2007) Log Message: ----------- More/better logging. 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-09-19 16:05:30 UTC (rev 23409) +++ trunk/launchd/src/launchd_core_logic.c 2007-09-19 16:14:50 UTC (rev 23410) @@ -451,6 +451,7 @@ /* file local globals */ static size_t total_children; +static size_t total_anon_children; static mach_port_t the_exception_server; static bool did_first_per_user_launchd_BootCache_hack; #define JOB_BOOTCACHE_HACK_CHECK(j) (j->per_user && !did_first_per_user_launchd_BootCache_hack && (j->mach_uid >= 500) && (j->mach_uid != (uid_t)-2)) @@ -534,7 +535,7 @@ EV_ADD|EV_ONESHOT, NOTE_SECONDS, j->exit_timeout, j) != -1); } - job_log(j, LOG_DEBUG, "Sent SIGTERM signal."); + job_log(j, LOG_DEBUG, "Sent SIGTERM signal"); } launch_data_t @@ -669,7 +670,7 @@ static void still_alive_with_check(void) { - jobmgr_log(root_jobmgr, LOG_NOTICE, "Still alive with %lu children.", total_children); + jobmgr_log(root_jobmgr, LOG_NOTICE, "Still alive with %lu/%lu children", total_children, total_anon_children); jobmgr_log_active_jobs(root_jobmgr); @@ -747,7 +748,7 @@ runtime_closelog(); } else { runtime_closelog(); - jobmgr_log(jm, LOG_DEBUG, "About to exit."); + jobmgr_log(jm, LOG_DEBUG, "About to exit"); exit(EXIT_SUCCESS); } @@ -769,7 +770,7 @@ if (j->p && j->anonymous) { job_reap(j); } else if (j->p) { - job_log(j, LOG_DEBUG, "Removal pended until the job exits."); + job_log(j, LOG_DEBUG, "Removal pended until the job exits"); if (!j->removal_pending) { j->removal_pending = true; @@ -1072,7 +1073,7 @@ if (jobmgr_assumes(jm, (jr = job_new(jm, AUTO_PICK_LEGACY_LABEL, zombie ? zombie : kp.kp_proc.p_comm, NULL)) != NULL)) { u_int proc_fflags = NOTE_EXEC|NOTE_EXIT /* |NOTE_REAP */; - total_children++; + total_anon_children++; jr->anonymous = true; jr->p = anonpid; @@ -1081,7 +1082,7 @@ if (kevent_mod(jr->p, EVFILT_PROC, EV_ADD, proc_fflags, 0, root_jobmgr) == -1 && job_assumes(jr, errno == ESRCH)) { /* zombies are weird */ - job_log(jr, LOG_ERR, "Failed to add kevent for PID %u. Will unload at MIG return.", jr->p); + job_log(jr, LOG_ERR, "Failed to add kevent for PID %u. Will unload at MIG return", jr->p); jr->unload_at_mig_return = true; } @@ -1090,7 +1091,7 @@ } if (shutdown_state && jm->hopefully_first_cnt == 0) { - job_log(jr, LOG_APPLEONLY, "This process showed up to the party while all the guests were leaving. Odds are that it will have a miserable time."); + job_log(jr, LOG_APPLEONLY, "This process showed up to the party while all the guests were leaving. Odds are that it will have a miserable time"); } job_log(jr, LOG_DEBUG, "Created PID %u anonymously by PPID %u%s%s", anonpid, kp.kp_eproc.e_ppid, jp ? ": " : "", jp ? jp->label : ""); @@ -2025,10 +2026,12 @@ kevent_mod((uintptr_t)&j->exit_timeout, EVFILT_TIMER, EV_DELETE, 0, 0, NULL); } - if (!j->anonymous) { + if (j->anonymous) { + total_anon_children--; + } else { runtime_del_ref(); + total_children--; } - total_children--; LIST_REMOVE(j, pid_hash_sle); if (j->wait_reply_port) { @@ -3660,7 +3663,7 @@ job_log(j, LOG_DEBUG, "Exited while removal was pending."); return true; } else if (j->mgr->shutting_down) { - job_log(j, LOG_DEBUG, "Exited while shutdown in progress. Processes remaining: %lu", total_children); + job_log(j, LOG_DEBUG, "Exited while shutdown in progress. Processes remaining: %lu/%lu", total_children, total_anon_children); return true; } else if (j->legacy_mach_job) { if (SLIST_EMPTY(&j->machservices)) { -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070919/d3969ca5/attachment.html From source_changes at macosforge.org Wed Sep 19 09:22:41 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:54 2007 Subject: [launchd-changes] [23411] trunk/launchd/src/launchd_runtime.c Message-ID: <20070919162241.3149D7CBEC4@cvs.opensource.apple.com> Revision: 23411 http://trac.macosforge.org/projects/launchd/changeset/23411 Author: zarzycki@apple.com Date: 2007-09-19 09:22:39 -0700 (Wed, 19 Sep 2007) Log Message: ----------- This false positive bug line needs to be fixed. Modified Paths: -------------- trunk/launchd/src/launchd_runtime.c Modified: trunk/launchd/src/launchd_runtime.c =================================================================== --- trunk/launchd/src/launchd_runtime.c 2007-09-19 16:14:50 UTC (rev 23410) +++ trunk/launchd/src/launchd_runtime.c 2007-09-19 16:22:39 UTC (rev 23411) @@ -1274,7 +1274,8 @@ tmp_port = drain_reply_port; drain_reply_port = MACH_PORT_NULL; - if (!launchd_assumes((errno = job_mig_log_drain_reply(tmp_port, 0, outval, outvalCnt)) == 0)) { + if ((errno = job_mig_log_drain_reply(tmp_port, 0, outval, outvalCnt))) { + launchd_assumes(errno == MACH_SEND_INVALID_DEST); launchd_assumes(launchd_mport_deallocate(tmp_port) == KERN_SUCCESS); } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070919/ecf3384a/attachment.html From source_changes at macosforge.org Wed Sep 19 10:38:36 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:54 2007 Subject: [launchd-changes] [23412] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070919173836.28C017CBFFD@cvs.opensource.apple.com> Revision: 23412 http://trac.macosforge.org/projects/launchd/changeset/23412 Author: zarzycki@apple.com Date: 2007-09-19 10:38:35 -0700 (Wed, 19 Sep 2007) Log Message: ----------- More logging. 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-09-19 16:22:39 UTC (rev 23411) +++ trunk/launchd/src/launchd_core_logic.c 2007-09-19 17:38:35 UTC (rev 23412) @@ -401,6 +401,7 @@ static void job_callback_proc(job_t j, int flags, int fflags); static void job_callback_timer(job_t j, void *ident); static void job_callback_read(job_t j, int ident); +static void job_log_stray_pg(job_t j); static job_t job_new_anonymous(jobmgr_t jm, pid_t anonpid); static job_t job_new(jobmgr_t jm, const char *label, const char *prog, const char *const *argv); static job_t job_new_via_mach_init(job_t j, const char *cmd, uid_t uid, bool ond); @@ -1961,6 +1962,39 @@ } void +job_log_stray_pg(job_t j) +{ + int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PGRP, j->p }; + size_t i, kp_cnt, len = 10*1024*1024; + struct kinfo_proc *kp; + + if (!job_assumes(j, (kp = malloc(len)) != NULL)) { + return; + } + if (!job_assumes(j, sysctl(mib, 4, 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; + const char *z = (kp[i].kp_proc.p_stat == SZOMB) ? "zombie " : ""; + const char *n = kp[i].kp_proc.p_comm; + + if (!job_assumes(j, p_i != 0 && p_i != 1)) { + continue; + } + + job_log(j, LOG_WARNING, "Stray %sprocess with PGID equal to this dead job: PID %u PPID %u %s", z, p_i, pp_i, n); + } + +out: + free(kp); +} + +void job_reap(job_t j) { struct rusage ru; @@ -1998,6 +2032,7 @@ * valid, try to kill abandoned descendant processes. */ if (!j->abandon_pg) { + job_log_stray_pg(j); job_assumes(j, runtime_killpg(j->p, SIGKILL) != -1 || errno == ESRCH); } @@ -4127,7 +4162,7 @@ pid_t p_i = kp[i].kp_proc.p_pid; pid_t pp_i = kp[i].kp_eproc.e_ppid; pid_t pg_i = kp[i].kp_eproc.e_pgid; - const char *z = kp[i].kp_proc.p_stat == SZOMB ? "zombie " : ""; + const char *z = (kp[i].kp_proc.p_stat == SZOMB) ? "zombie " : ""; const char *n = kp[i].kp_proc.p_comm; if (p_i == 0 || p_i == 1) { -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070919/1f3ca84d/attachment.html From source_changes at macosforge.org Wed Sep 19 10:41:53 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:54 2007 Subject: [launchd-changes] [23413] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070919174153.6CC507CC00E@cvs.opensource.apple.com> Revision: 23413 http://trac.macosforge.org/projects/launchd/changeset/23413 Author: zarzycki@apple.com Date: 2007-09-19 10:41:53 -0700 (Wed, 19 Sep 2007) Log Message: ----------- Let's be less harsh. 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-09-19 17:38:35 UTC (rev 23412) +++ trunk/launchd/src/launchd_core_logic.c 2007-09-19 17:41:53 UTC (rev 23413) @@ -2033,7 +2033,7 @@ */ if (!j->abandon_pg) { job_log_stray_pg(j); - job_assumes(j, runtime_killpg(j->p, SIGKILL) != -1 || errno == ESRCH); + job_assumes(j, runtime_killpg(j->p, SIGTERM) != -1 || errno == ESRCH); } /* -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070919/3040b042/attachment.html From source_changes at macosforge.org Wed Sep 19 10:47:37 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:54 2007 Subject: [launchd-changes] [23414] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070919174737.11EDF7CC027@cvs.opensource.apple.com> Revision: 23414 http://trac.macosforge.org/projects/launchd/changeset/23414 Author: zarzycki@apple.com Date: 2007-09-19 10:47:36 -0700 (Wed, 19 Sep 2007) Log Message: ----------- Duh. Don't log when PID == PGID. 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-09-19 17:41:53 UTC (rev 23413) +++ trunk/launchd/src/launchd_core_logic.c 2007-09-19 17:47:36 UTC (rev 23414) @@ -1983,8 +1983,10 @@ const char *z = (kp[i].kp_proc.p_stat == SZOMB) ? "zombie " : ""; const char *n = kp[i].kp_proc.p_comm; - if (!job_assumes(j, p_i != 0 && p_i != 1)) { + if (p_i == j->p) { continue; + } else if (!job_assumes(j, p_i != 0 && p_i != 1)) { + continue; } job_log(j, LOG_WARNING, "Stray %sprocess with PGID equal to this dead job: PID %u PPID %u %s", z, p_i, pp_i, n); @@ -2031,8 +2033,8 @@ * The job is dead. While the PID/PGID is still known to be * valid, try to kill abandoned descendant processes. */ + job_log_stray_pg(j); if (!j->abandon_pg) { - job_log_stray_pg(j); job_assumes(j, runtime_killpg(j->p, SIGTERM) != -1 || errno == ESRCH); } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070919/78936441/attachment.html From source_changes at macosforge.org Wed Sep 19 11:39:29 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:54 2007 Subject: [launchd-changes] [23415] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070919183929.1FF4E7CC160@cvs.opensource.apple.com> Revision: 23415 http://trac.macosforge.org/projects/launchd/changeset/23415 Author: zarzycki@apple.com Date: 2007-09-19 11:39:28 -0700 (Wed, 19 Sep 2007) Log Message: ----------- Code audit: order of operations problem can hang 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-09-19 17:47:36 UTC (rev 23414) +++ trunk/launchd/src/launchd_core_logic.c 2007-09-19 18:39:28 UTC (rev 23415) @@ -2015,7 +2015,7 @@ j->weird_bootstrap = false; } - if (j->log_redirect_fd && (!j->wait4pipe_eof || j->mgr->shutting_down)) { + if (j->log_redirect_fd && !j->wait4pipe_eof) { job_assumes(j, runtime_close(j->log_redirect_fd) != -1); j->log_redirect_fd = 0; } @@ -3844,14 +3844,20 @@ { struct machservice *ms; - if (j->wait4pipe_eof && j->log_redirect_fd) { - return "Standard out/error is still valid"; - } - if (j->p) { return "PID is still valid"; } + if (j->mgr->shutting_down && j->log_redirect_fd) { + job_assumes(j, runtime_close(j->log_redirect_fd) != -1); + j->log_redirect_fd = 0; + } + + if (j->log_redirect_fd) { + job_assumes(j, j->wait4pipe_eof); + return "Standard out/error is still valid"; + } + if (j->priv_port_has_senders) { return "Privileged Port still has outstanding senders"; } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070919/6c326ee1/attachment.html From source_changes at macosforge.org Wed Sep 19 15:00:26 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:54 2007 Subject: [launchd-changes] [23416] tags/launchd-250/ Message-ID: <20070919220026.C70F57CC5BA@cvs.opensource.apple.com> Revision: 23416 http://trac.macosforge.org/projects/launchd/changeset/23416 Author: zarzycki@apple.com Date: 2007-09-19 15:00:26 -0700 (Wed, 19 Sep 2007) Log Message: ----------- "Tagging launchd-250 from https://svn.macosforge.org/repository/launchd/trunk" Added Paths: ----------- tags/launchd-250/ Copied: tags/launchd-250 (from rev 23415, trunk) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070919/0bfb212d/attachment.html From source_changes at macosforge.org Wed Sep 19 15:30:57 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:54 2007 Subject: [launchd-changes] [23417] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070919223057.2D0A67CC653@cvs.opensource.apple.com> Revision: 23417 http://trac.macosforge.org/projects/launchd/changeset/23417 Author: zarzycki@apple.com Date: 2007-09-19 15:30:56 -0700 (Wed, 19 Sep 2007) Log Message: ----------- 9A558: Adobe Creative Suite 3 installer dies after auth and initialization dialog 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-09-19 22:00:26 UTC (rev 23416) +++ trunk/launchd/src/launchd_core_logic.c 2007-09-19 22:30:56 UTC (rev 23417) @@ -6378,6 +6378,7 @@ jr->unload_at_exit = true; jr->wait4pipe_eof = true; + jr->abandon_pg = true; jr->stall_before_exec = jr->wait4debugger; jr->wait4debugger = false; -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070919/10e71bb7/attachment.html From source_changes at macosforge.org Wed Sep 19 18:54:51 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:54 2007 Subject: [launchd-changes] [23418] tags/launchd-251/ Message-ID: <20070920015451.AA17C7CCB41@cvs.opensource.apple.com> Revision: 23418 http://trac.macosforge.org/projects/launchd/changeset/23418 Author: kvv@apple.com Date: 2007-09-19 18:54:50 -0700 (Wed, 19 Sep 2007) Log Message: ----------- "Tagging launchd-251 from http://svn.macosforge.org/repository/launchd/trunk" Added Paths: ----------- tags/launchd-251/ Copied: tags/launchd-251 (from rev 23417, trunk) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070919/e6c08502/attachment.html From source_changes at macosforge.org Thu Sep 20 13:23:58 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:54 2007 Subject: [launchd-changes] [23419] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070920202358.50D767CF0B7@cvs.opensource.apple.com> Revision: 23419 http://trac.macosforge.org/projects/launchd/changeset/23419 Author: zarzycki@apple.com Date: 2007-09-20 13:23:58 -0700 (Thu, 20 Sep 2007) Log Message: ----------- Workaround 5226811, 3524219, and 4124079 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-09-20 01:54:50 UTC (rev 23418) +++ trunk/launchd/src/launchd_core_logic.c 2007-09-20 20:23:58 UTC (rev 23419) @@ -359,7 +359,8 @@ 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, wait4pipe_eof:1, sent_sigkill:1, debug_before_kill:1, weird_bootstrap:1, start_on_mount:1, - per_user:1, hopefully_exits_first:1, deny_unknown_mslookups:1, unload_at_mig_return:1, abandon_pg:1; + per_user:1, hopefully_exits_first:1, deny_unknown_mslookups:1, unload_at_mig_return:1, abandon_pg:1, + poll_for_vfs_changes:1; const char label[0]; }; @@ -480,6 +481,11 @@ j->currently_ignored = true; + if (j->poll_for_vfs_changes) { + j->poll_for_vfs_changes = false; + job_assumes(j, kevent_mod((uintptr_t)&j->semaphores, EVFILT_TIMER, EV_DELETE, 0, 0, j) != -1); + } + SLIST_FOREACH(sg, &j->sockets, sle) { socketgroup_ignore(j, sg); } @@ -868,6 +874,9 @@ runtime_del_ref(); job_assumes(j, kevent_mod((uintptr_t)&j->start_interval, EVFILT_TIMER, EV_DELETE, 0, 0, NULL) != -1); } + if (j->poll_for_vfs_changes) { + job_assumes(j, kevent_mod((uintptr_t)&j->semaphores, EVFILT_TIMER, EV_DELETE, 0, 0, j) != -1); + } kevent_mod((uintptr_t)j, EVFILT_TIMER, EV_DELETE, 0, 0, NULL); @@ -2307,6 +2316,8 @@ { if (j == ident) { job_dispatch(j, true); + } else if (&j->semaphores == ident) { + job_dispatch(j, false); } else if (&j->start_interval == ident) { j->start_pending = true; job_dispatch(j, false); @@ -3246,7 +3257,7 @@ } if (si->fd == -1) { - return job_log_error(j, LOG_ERR, "Watchpath monitoring failed on \"%s\"", which_path); + return job_log_error(j, LOG_ERR, "Path monitoring failed on \"%s\"", which_path); } job_log(j, LOG_DEBUG, "Watching Vnode: %d", si->fd); @@ -3263,6 +3274,20 @@ si->fd = -1; } } while ((si->fd == -1) && (saved_errno == ENOENT)); + + if (saved_errno == ENOTSUP) { + /* + * 3524219 NFS needs kqueue support + * 4124079 VFS needs generic kqueue support + * 5226811 EVFILT: Launchd EVFILT_VNODE doesn't work on /dev + */ + job_log(j, LOG_DEBUG, "Falling back to polling for path: %s", si->what); + + if (!j->poll_for_vfs_changes) { + j->poll_for_vfs_changes = true; + job_assumes(j, kevent_mod((uintptr_t)&j->semaphores, EVFILT_TIMER, EV_ADD, NOTE_SECONDS, 3, j) != -1); + } + } } void @@ -3815,7 +3840,7 @@ break; case DIR_NOT_EMPTY: if (-1 == (qdir_file_cnt = dir_has_files(j, si->what))) { - job_log_error(j, LOG_ERR, "dir_has_files(\"%s\", ...)", si->what); + job_log_error(j, LOG_ERR, "Failed to count the number of files in \"%s\"", si->what); } else if (qdir_file_cnt > 0) { job_log(j, LOG_DEBUG, "KeepAlive: Directory is not empty: %s", si->what); return true; -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070920/27b979c5/attachment.html From source_changes at macosforge.org Thu Sep 20 13:26:16 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:54 2007 Subject: [launchd-changes] [23420] tags/launchd-252/ Message-ID: <20070920202616.CBCF57CF0BF@cvs.opensource.apple.com> Revision: 23420 http://trac.macosforge.org/projects/launchd/changeset/23420 Author: zarzycki@apple.com Date: 2007-09-20 13:26:16 -0700 (Thu, 20 Sep 2007) Log Message: ----------- "Tagging launchd-252 from https://svn.macosforge.org/repository/launchd/trunk" Added Paths: ----------- tags/launchd-252/ Copied: tags/launchd-252 (from rev 23419, trunk) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070920/271f29e5/attachment.html From source_changes at macosforge.org Thu Sep 20 16:05:54 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:54 2007 Subject: [launchd-changes] [23421] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070920230554.CA54D7CF496@cvs.opensource.apple.com> Revision: 23421 http://trac.macosforge.org/projects/launchd/changeset/23421 Author: zarzycki@apple.com Date: 2007-09-20 16:05:54 -0700 (Thu, 20 Sep 2007) Log Message: ----------- cannot drop to text console 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-09-20 20:26:16 UTC (rev 23420) +++ trunk/launchd/src/launchd_core_logic.c 2007-09-20 23:05:54 UTC (rev 23421) @@ -2942,10 +2942,15 @@ setenv(ei->key, ei->value, 1); } - if (j->per_user) { + /* + * We'd like to call setsid() unconditionally, but we have reason to + * believe that prevents launchd from being able to send signals to + * setuid children. We'll settle for process-groups. + */ + if (getuid()) { + job_assumes(j, setpgid(0, 0) != -1); + } else { job_assumes(j, setsid() != -1); - } else { - job_assumes(j, setpgid(0, 0) != -1); } } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070920/77d31b09/attachment.html From source_changes at macosforge.org Thu Sep 20 16:22:05 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:54 2007 Subject: [launchd-changes] [23422] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070920232205.288FC7CF508@cvs.opensource.apple.com> Revision: 23422 http://trac.macosforge.org/projects/launchd/changeset/23422 Author: zarzycki@apple.com Date: 2007-09-20 16:22:05 -0700 (Thu, 20 Sep 2007) Log Message: ----------- We've already dropped privs. Use a different check. 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-09-20 23:05:54 UTC (rev 23421) +++ trunk/launchd/src/launchd_core_logic.c 2007-09-20 23:22:05 UTC (rev 23422) @@ -2947,7 +2947,7 @@ * believe that prevents launchd from being able to send signals to * setuid children. We'll settle for process-groups. */ - if (getuid()) { + if (getppid() != 1) { job_assumes(j, setpgid(0, 0) != -1); } else { job_assumes(j, setsid() != -1); -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070920/bdd5f462/attachment.html From source_changes at macosforge.org Fri Sep 21 13:36:01 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:54 2007 Subject: [launchd-changes] [23423] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070921203601.973417D4106@cvs.opensource.apple.com> Revision: 23423 http://trac.macosforge.org/projects/launchd/changeset/23423 Author: zarzycki@apple.com Date: 2007-09-21 13:36:00 -0700 (Fri, 21 Sep 2007) Log Message: ----------- tftpd needs to adopt launchd AbandonProcessGroup key 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-09-20 23:22:05 UTC (rev 23422) +++ trunk/launchd/src/launchd_core_logic.c 2007-09-21 20:36:00 UTC (rev 23423) @@ -1566,6 +1566,7 @@ case 'I': if (strcasecmp(key, LAUNCH_JOBKEY_INETDCOMPATIBILITY) == 0) { j->inetcompat = true; + j->abandon_pg = true; if ((tmp = launch_data_dict_lookup(value, LAUNCH_JOBINETDCOMPATIBILITY_WAIT))) { j->inetcompat_wait = launch_data_get_bool(tmp); } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070921/e8f40d52/attachment.html From source_changes at macosforge.org Fri Sep 21 13:36:09 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:55 2007 Subject: [launchd-changes] [23424] tags/launchd-253/ Message-ID: <20070921203609.00B4E7D410A@cvs.opensource.apple.com> Revision: 23424 http://trac.macosforge.org/projects/launchd/changeset/23424 Author: zarzycki@apple.com Date: 2007-09-21 13:36:08 -0700 (Fri, 21 Sep 2007) Log Message: ----------- "Tagging launchd-253 from https://svn.macosforge.org/repository/launchd/trunk" Added Paths: ----------- tags/launchd-253/ Copied: tags/launchd-253 (from rev 23423, trunk) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070921/89a6a951/attachment.html From source_changes at macosforge.org Fri Sep 21 16:25:52 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:55 2007 Subject: [launchd-changes] [23425] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070921232552.C3E197D4388@cvs.opensource.apple.com> Revision: 23425 http://trac.macosforge.org/projects/launchd/changeset/23425 Author: zarzycki@apple.com Date: 2007-09-21 16:25:52 -0700 (Fri, 21 Sep 2007) Log Message: ----------- Leopard: M67 Hang on the way to power-off 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-09-21 20:36:08 UTC (rev 23424) +++ trunk/launchd/src/launchd_core_logic.c 2007-09-21 23:25:52 UTC (rev 23425) @@ -4122,6 +4122,19 @@ jobmgr_log(jm, LOG_DEBUG, "Garbage collecting."); + /* + * Normally, we wait for all resources of a job (Unix PIDs/FDs and Mach ports) + * to reset before we conider the job truly dead and ready to be spawned again. + * + * In order to work around 5487724 and 3456090, we're going to call reboot() + * when the last PID dies and not wait for the associated resources to reset. + */ + if (getpid() == 1 && jm->parentmgr == NULL && total_children == 0) { + jobmgr_log(jm, LOG_DEBUG, "About to force a call to: reboot(%s)", reboot_flags_to_C_names(jm->reboot_flags)); + runtime_closelog(); + jobmgr_assumes(jm, reboot(jm->reboot_flags) != -1); + } + if (jm->hopefully_first_cnt) { return jm; } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070921/6accc760/attachment.html From source_changes at macosforge.org Fri Sep 21 16:26:08 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:55 2007 Subject: [launchd-changes] [23426] tags/launchd-254/ Message-ID: <20070921232608.283137D438D@cvs.opensource.apple.com> Revision: 23426 http://trac.macosforge.org/projects/launchd/changeset/23426 Author: zarzycki@apple.com Date: 2007-09-21 16:26:07 -0700 (Fri, 21 Sep 2007) Log Message: ----------- "Tagging launchd-254 from https://svn.macosforge.org/repository/launchd/trunk" Added Paths: ----------- tags/launchd-254/ Copied: tags/launchd-254 (from rev 23425, trunk) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070921/11264f90/attachment.html From source_changes at macosforge.org Fri Sep 21 19:46:21 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:55 2007 Subject: [launchd-changes] [23427] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070922024621.05BEF7D45E3@cvs.opensource.apple.com> Revision: 23427 http://trac.macosforge.org/projects/launchd/changeset/23427 Author: zarzycki@apple.com Date: 2007-09-21 19:46:20 -0700 (Fri, 21 Sep 2007) Log Message: ----------- Regression:VO QuickStart not working in 9A558 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-09-21 23:26:07 UTC (rev 23426) +++ trunk/launchd/src/launchd_core_logic.c 2007-09-22 02:46:20 UTC (rev 23427) @@ -992,6 +992,7 @@ jr->mach_uid = uid; jr->ondemand = ond; jr->legacy_mach_job = true; + jr->abandon_pg = true; jr->priv_port_has_senders = true; /* the IPC that called us will make-send on this port */ if (!job_setup_machport(jr)) { -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070921/00648d1d/attachment.html From source_changes at macosforge.org Sun Sep 23 11:44:42 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:55 2007 Subject: [launchd-changes] [23428] tags/launchd-255/ Message-ID: <20070923184442.77A097D6B16@cvs.opensource.apple.com> Revision: 23428 http://trac.macosforge.org/projects/launchd/changeset/23428 Author: zarzycki@apple.com Date: 2007-09-23 11:44:41 -0700 (Sun, 23 Sep 2007) Log Message: ----------- "Tagging launchd-255 from https://svn.macosforge.org/repository/launchd/trunk" Added Paths: ----------- tags/launchd-255/ Copied: tags/launchd-255 (from rev 23427, trunk) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070923/4b69dc30/attachment.html From source_changes at macosforge.org Tue Sep 25 10:15:33 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:55 2007 Subject: [launchd-changes] [23429] trunk/launchd/src/StartupItems.c Message-ID: <20070925171533.83B247DBC39@cvs.opensource.apple.com> Revision: 23429 http://trac.macosforge.org/projects/launchd/changeset/23429 Author: zarzycki@apple.com Date: 2007-09-25 10:15:32 -0700 (Tue, 25 Sep 2007) Log Message: ----------- just installed startupitem will not start Modified Paths: -------------- trunk/launchd/src/StartupItems.c Modified: trunk/launchd/src/StartupItems.c =================================================================== --- trunk/launchd/src/StartupItems.c 2007-09-23 18:44:41 UTC (rev 23428) +++ trunk/launchd/src/StartupItems.c 2007-09-25 17:15:32 UTC (rev 23429) @@ -239,7 +239,11 @@ syslog(LOG_ERR, "lstat(\"%s\"): %m", aPath); return false; } - if (aStatBuf.st_ctimespec.tv_sec > boot_time.tv_sec) { + /* + * We check the boot time because of 5409386. + * We ignore the boot time if PPID != 1 because of 5503536. + */ + if ((aStatBuf.st_ctimespec.tv_sec > boot_time.tv_sec) && (getppid() == 1)) { syslog(LOG_WARNING, "\"%s\" failed sanity check: path was created after boot up", aPath); return false; } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070925/6a045ccc/attachment.html From source_changes at macosforge.org Tue Sep 25 10:18:45 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:55 2007 Subject: [launchd-changes] [23430] trunk/launchd/src/launchd_core_logic.c Message-ID: <20070925171845.E57AB7DBC41@cvs.opensource.apple.com> Revision: 23430 http://trac.macosforge.org/projects/launchd/changeset/23430 Author: zarzycki@apple.com Date: 2007-09-25 10:18:45 -0700 (Tue, 25 Sep 2007) Log Message: ----------- PubSubAgent isn't launched on schedule by launchd [PubSub isn't automatically refreshing] 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-09-25 17:15:32 UTC (rev 23429) +++ trunk/launchd/src/launchd_core_logic.c 2007-09-25 17:18:45 UTC (rev 23430) @@ -5365,6 +5365,9 @@ } else if (inval) { if (j->start_interval == 0) { runtime_add_ref(); + } else { + /* Workaround 5225889 */ + job_assumes(j, kevent_mod((uintptr_t)&j->start_interval, EVFILT_TIMER, EV_DELETE, 0, 0, j) != -1); } j->start_interval = inval; job_assumes(j, kevent_mod((uintptr_t)&j->start_interval, EVFILT_TIMER, EV_ADD, NOTE_SECONDS, j->start_interval, j) != -1); -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070925/2cfaf6af/attachment.html From source_changes at macosforge.org Tue Sep 25 13:37:53 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:55 2007 Subject: [launchd-changes] [23431] tags/launchd-256/ Message-ID: <20070925203753.4821F7DC244@cvs.opensource.apple.com> Revision: 23431 http://trac.macosforge.org/projects/launchd/changeset/23431 Author: zarzycki@apple.com Date: 2007-09-25 13:37:53 -0700 (Tue, 25 Sep 2007) Log Message: ----------- "Tagging launchd-256 from https://svn.macosforge.org/repository/launchd/trunk" Added Paths: ----------- tags/launchd-256/ Copied: tags/launchd-256 (from rev 23430, trunk) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070925/2e618b27/attachment.html From source_changes at macosforge.org Thu Sep 27 10:02:24 2007 From: source_changes at macosforge.org (source_changes@macosforge.org) Date: Tue Oct 9 16:25:55 2007 Subject: [launchd-changes] [23432] trunk/launchd/src Message-ID: <20070927170224.45AB18122CF@cvs.opensource.apple.com> Revision: 23432 http://trac.macosforge.org/projects/launchd/changeset/23432 Author: zarzycki@apple.com Date: 2007-09-27 10:02:23 -0700 (Thu, 27 Sep 2007) Log Message: ----------- A debug function plus some random code comments. Modified Paths: -------------- trunk/launchd/src/launchd_runtime.c trunk/launchd/src/launchd_runtime.h Modified: trunk/launchd/src/launchd_runtime.c =================================================================== --- trunk/launchd/src/launchd_runtime.c 2007-09-25 20:37:53 UTC (rev 23431) +++ trunk/launchd/src/launchd_runtime.c 2007-09-27 17:02:23 UTC (rev 23432) @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -180,6 +181,70 @@ } const char * +proc_flags_to_C_names(unsigned int flags) +{ +#define MAX_PFLAG_STR "P_ADVLOCK|P_CONTROLT|P_LP64|P_NOCLDSTOP|P_PPWAIT|P_PROFIL|P_SELECT|P_CONTINUED|P_SUGID|P_SYSTEM|P_TIMEOUT|P_TRACED|P_RESV3|P_WEXIT|P_EXEC|P_OWEUPC|P_AFFINITY|P_TRANSLATED|P_RESV5|P_CHECKOPENEVT|P_DEPENDENCY_CAPABLE|P_REBOOT|P_TBE|P_RESV7|P_THCWD|P_RESV9|P_RESV10|P_RESV11|P_NOSHLIB|P_FORCEQUOTA|P_NOCLDWAIT|P_NOREMOTEHANG|0xdeadbeeffeedface" + + static char flags_buf[sizeof(MAX_PFLAG_STR)]; + char *flags_off = NULL; + + if (!flags) { + return ""; + } + + while (flags) { + if (flags_off) { + *flags_off = '|'; + flags_off++; + *flags_off = '\0'; + } else { + flags_off = flags_buf; + } + +#define FLAGIF(f) if (flags & f) { flags_off += sprintf(flags_off, #f); flags &= ~f; } + + FLAGIF(P_ADVLOCK) + else FLAGIF(P_CONTROLT) + else FLAGIF(P_LP64) + else FLAGIF(P_NOCLDSTOP) + else FLAGIF(P_PPWAIT) + else FLAGIF(P_PROFIL) + else FLAGIF(P_SELECT) + else FLAGIF(P_CONTINUED) + else FLAGIF(P_SUGID) + else FLAGIF(P_SYSTEM) + else FLAGIF(P_TIMEOUT) + else FLAGIF(P_TRACED) + else FLAGIF(P_RESV3) + else FLAGIF(P_WEXIT) + else FLAGIF(P_EXEC) + else FLAGIF(P_OWEUPC) + else FLAGIF(P_AFFINITY) + else FLAGIF(P_TRANSLATED) + else FLAGIF(P_RESV5) + else FLAGIF(P_CHECKOPENEVT) + else FLAGIF(P_DEPENDENCY_CAPABLE) + else FLAGIF(P_REBOOT) + else FLAGIF(P_TBE) + else FLAGIF(P_RESV7) + else FLAGIF(P_THCWD) + else FLAGIF(P_RESV9) + else FLAGIF(P_RESV10) + else FLAGIF(P_RESV11) + else FLAGIF(P_NOSHLIB) + else FLAGIF(P_FORCEQUOTA) + else FLAGIF(P_NOCLDWAIT) + else FLAGIF(P_NOREMOTEHANG) + else { + flags_off += sprintf(flags_off, "0x%x", flags); + flags = 0; + } + } + + return flags_buf; +} + +const char * reboot_flags_to_C_names(unsigned int flags) { #define MAX_RB_STR "RB_ASKNAME|RB_SINGLE|RB_NOSYNC|RB_KDB|RB_HALT|RB_INITNAME|RB_DFLTROOT|RB_ALTBOOT|RB_UNIPROC|RB_SAFEBOOT|RB_UPSDELAY|0xdeadbeeffeedface" @@ -195,8 +260,6 @@ flags_off = flags_buf; } -#define FLAGIF(f) if (flags & f) { flags_off += sprintf(flags_off, #f); flags &= ~f; } - FLAGIF(RB_ASKNAME) else FLAGIF(RB_SINGLE) else FLAGIF(RB_NOSYNC) @@ -478,6 +541,14 @@ { fd_set rfds; + /* + * Yes, at first glance, calling select() on a kqueue seems silly. + * + * This avoids a race condition between the main thread and this helper + * thread by ensuring that we drain kqueue events on the same thread + * that manipulates the kqueue. + */ + for (;;) { FD_ZERO(&rfds); FD_SET(mainkq, &rfds); @@ -1356,6 +1427,15 @@ return runtime_log_pack(outval, outvalCnt); } +/* + * We should break this into two reference counts. + * + * One for hard references that would prevent exiting. + * One for soft references that would only prevent idle exiting. + * + * In the long run, reference counting should completely automate when a + * process can and should exit. + */ void runtime_add_ref(void) { Modified: trunk/launchd/src/launchd_runtime.h =================================================================== --- trunk/launchd/src/launchd_runtime.h 2007-09-25 20:37:53 UTC (rev 23431) +++ trunk/launchd/src/launchd_runtime.h 2007-09-27 17:02:23 UTC (rev 23432) @@ -77,6 +77,7 @@ const char *signal_to_C_name(unsigned int sig); const char *reboot_flags_to_C_names(unsigned int flags); +const char *proc_flags_to_C_names(unsigned int flags); int kevent_bulk_mod(struct kevent *kev, size_t kev_cnt); -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20070927/34d53f0a/attachment.html