From source_changes at macosforge.org Fri May 1 10:47:55 2009 From: source_changes at macosforge.org (source_changes at macosforge.org) Date: Fri, 1 May 2009 10:47:55 -0700 (PDT) Subject: [launchd-changes] [23916] trunk/launchd/src Message-ID: <20090501174755.9490916DD196@beta.macosforge.org> Revision: 23916 http://trac.macosforge.org/projects/launchd/changeset/23916 Author: dsorresso at apple.com Date: 2009-05-01 10:47:54 -0700 (Fri, 01 May 2009) Log Message: ----------- We're still leaving zombies around when logging out 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 2009-04-30 23:34:49 UTC (rev 23915) +++ trunk/launchd/src/launchd.c 2009-05-01 17:47:54 UTC (rev 23916) @@ -164,15 +164,9 @@ if( pid1_magic ) { if( low_level_debug ) { g_console = stdout; - } else { - if( !launchd_assumes((g_console = fopen(_PATH_CONSOLE, "w")) != NULL) ) { - g_console = stdout; - } else { - _fd(fileno(g_console)); - } + } else if( launchd_assumes((g_console = fopen(_PATH_CONSOLE, "w")) != NULL) ) { + _fd(fileno(g_console)); } - } else { - g_console = stdout; } if (NULL == getenv("PATH")) { @@ -205,9 +199,9 @@ } if( pid1_magic ) { - runtime_syslog(LOG_NOTICE | LOG_CONSOLE_FORCE, "*** launchd[1] has started up. ***"); + runtime_syslog(LOG_NOTICE | LOG_CONSOLE, "*** launchd[1] has started up. ***"); if( g_use_gmalloc ) { - runtime_syslog(LOG_NOTICE | LOG_CONSOLE_FORCE, "*** Using libgmalloc ***"); + runtime_syslog(LOG_NOTICE | LOG_CONSOLE, "*** Using libgmalloc ***"); } if( g_verbose_boot ) { @@ -215,7 +209,7 @@ } if( g_shutdown_debugging ) { - runtime_syslog(LOG_NOTICE | LOG_CONSOLE_FORCE, "*** Shutdown debugging is enabled. ***"); + runtime_syslog(LOG_NOTICE | LOG_CONSOLE, "*** Shutdown debugging is enabled. ***"); } /* PID 1 doesn't have a flat namespace. */ @@ -304,7 +298,7 @@ switch ((p = fork())) { case -1: - runtime_syslog(LOG_ERR | LOG_CONSOLE_FORCE, "Can't fork PID 1 copy for crash debugging: %m"); + runtime_syslog(LOG_ERR | LOG_CONSOLE, "Can't fork PID 1 copy for crash debugging: %m"); return p; case 0: return p; @@ -339,10 +333,14 @@ /* Neuter our bootstrap port so that the shell doesn't try talking to us while * we're blocked waiting on it. */ - fflush(g_console); + if( g_console ) { + fflush(g_console); + } task_set_bootstrap_port(mach_task_self(), MACH_PORT_NULL); if( basic_fork() != 0 ) { - fflush(g_console); + if( g_console ) { + fflush(g_console); + } return true; } } else { @@ -435,7 +433,7 @@ }; if( !launchd_assumes(setaudit_addr(&auinfo, sizeof(auinfo)) != -1) ) { - runtime_syslog(LOG_WARNING | LOG_CONSOLE_FORCE, "Could not set audit session: %s.", strerror(errno)); + runtime_syslog(LOG_WARNING | LOG_CONSOLE, "Could not set audit session: %s.", strerror(errno)); _exit(EXIT_FAILURE); } Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2009-04-30 23:34:49 UTC (rev 23915) +++ trunk/launchd/src/launchd_core_logic.c 2009-05-01 17:47:54 UTC (rev 23916) @@ -3057,7 +3057,7 @@ va_list ap; va_start(ap, msg); - runtime_vsyslog(&attr, false, msg, ap); + runtime_vsyslog(&attr, msg, ap); va_end(ap); } @@ -3499,7 +3499,7 @@ jobmgr_assumes(root_jobmgr, runtime_close(s_no_hang_fd) != -1); s_no_hang_fd = _fd(_no_hang_fd); } - } else if( kev->ident == (uintptr_t)fileno(g_console) ) { + } else if( pid1_magic && g_console && kev->ident == (uintptr_t)fileno(g_console) ) { int cfd = -1; if( low_level_debug ) { if( jobmgr_assumes(jm, (stdout = freopen(_PATH_CONSOLE, "w", stdout)) != NULL) ) { @@ -3511,8 +3511,11 @@ cfd = fileno(g_console); } } - jobmgr_assumes(jm, kevent_mod((uintptr_t)cfd, EVFILT_VNODE, EV_ADD | EV_ONESHOT, NOTE_REVOKE, 0, jm) != -1); - _fd(cfd); + + if( cfd != -1 ) { + jobmgr_assumes(jm, kevent_mod((uintptr_t)cfd, EVFILT_VNODE, EV_ADD | EV_ONESHOT, NOTE_REVOKE, 0, jm) != -1); + _fd(cfd); + } } break; default: @@ -4382,12 +4385,9 @@ void job_logv(job_t j, int pri, int err, const char *msg, va_list ap) { - bool log_to_console = pri & LOG_CONSOLE; - int _pri = pri & ~LOG_CONSOLE; - const char *label2use = j ? j->label : "com.apple.launchd.NULL"; const char *mgr2use = j ? j->mgr->name : "NULL"; - struct runtime_syslog_attr attr = { g_my_label, label2use, mgr2use, _pri, getuid(), getpid(), j ? j->p : 0 }; + struct runtime_syslog_attr attr = { g_my_label, label2use, mgr2use, pri, getuid(), getpid(), j ? j->p : 0 }; char *newmsg; int oldmask = 0; size_t newmsgsz; @@ -4422,7 +4422,7 @@ oldmask = setlogmask(LOG_UPTO(LOG_DEBUG)); } - runtime_vsyslog(&attr, log_to_console, newmsg, ap); + runtime_vsyslog(&attr, newmsg, ap); if( j && unlikely(j->debug) ) { setlogmask(oldmask); @@ -4500,12 +4500,9 @@ if (jm->parentmgr) { jobmgr_logv(jm->parentmgr, pri, 0, newmsg, ap); } else { - bool log_to_console = pri & LOG_CONSOLE; - int _pri = pri & ~LOG_CONSOLE; - - struct runtime_syslog_attr attr = { g_my_label, g_my_label, jm->name, _pri, getuid(), getpid(), getpid() }; + struct runtime_syslog_attr attr = { g_my_label, g_my_label, jm->name, pri, getuid(), getpid(), getpid() }; - runtime_vsyslog(&attr, log_to_console, newmsg, ap); + runtime_vsyslog(&attr, newmsg, ap); } } @@ -5595,16 +5592,20 @@ if( !ji->stopped ) { job_log(ji, LOG_DEBUG, "Stopping job."); job_stop(ji); - if( !ji->clean_kill ) { - unkilled_cnt++; - } + unkilled_cnt++; } else { if( ji->clean_kill ) { job_log(ji, LOG_DEBUG, "Job was clean and sent SIGKILL."); + if( !ji->clean_exit_timer_expired ) { + /* Give jobs that were clean and sent SIGKILL 1 second to exit after receipt. */ + unkilled_cnt++; + } else { + job_log(ji, LOG_ERR, "Job was clean, killed and has not exited after 1 second. Moving on."); + } } else { job_log(ji, LOG_DEBUG, "Job was sent SIGTERM%s.", ji->sent_sigkill ? " and SIGKILL" : ""); + unkilled_cnt += !ji->sent_sigkill; } - unkilled_cnt += !ji->sent_sigkill; } } else { job_log(ji, LOG_DEBUG, "Job is active: %s", active); @@ -5960,7 +5961,9 @@ bootstrapper->stdoutpath = strdup(_PATH_CONSOLE); bootstrapper->stderrpath = strdup(_PATH_CONSOLE); - jobmgr_assumes(jm, kevent_mod((uintptr_t)fileno(g_console), EVFILT_VNODE, EV_ADD | EV_ONESHOT, NOTE_REVOKE, 0, jm) != -1); + if( g_console ) { + jobmgr_assumes(jm, kevent_mod((uintptr_t)fileno(g_console), EVFILT_VNODE, EV_ADD | EV_ONESHOT, NOTE_REVOKE, 0, jm) != -1); + } } } Modified: trunk/launchd/src/launchd_runtime.c =================================================================== --- trunk/launchd/src/launchd_runtime.c 2009-04-30 23:34:49 UTC (rev 23915) +++ trunk/launchd/src/launchd_runtime.c 2009-05-01 17:47:54 UTC (rev 23916) @@ -1246,14 +1246,11 @@ void runtime_syslog(int pri, const char *message, ...) { - bool log_to_console = (( pri & LOG_CONSOLE ) && g_verbose_boot) || ( pri & LOG_CONSOLE_FORCE ); - int _pri = pri & ~(LOG_CONSOLE | LOG_CONSOLE_FORCE); - struct runtime_syslog_attr attr = { g_my_label, g_my_label, pid1_magic ? "System" : "Background", - _pri, + pri, getuid(), getpid(), getpid() @@ -1261,16 +1258,17 @@ va_list ap; va_start(ap, message); - runtime_vsyslog(&attr, log_to_console, message, ap); + runtime_vsyslog(&attr, message, ap); va_end(ap); } void -runtime_vsyslog(struct runtime_syslog_attr *attr, bool echo_to_console, const char *message, va_list args) +runtime_vsyslog(struct runtime_syslog_attr *attr, const char *message, va_list args) { int saved_errno = errno; char newmsg[10000]; + bool echo_to_console= false; if (attr->priority == LOG_APPLEONLY) { if (do_apple_internal_logging) { @@ -1282,6 +1280,11 @@ attr->priority = g_log_strict_usage ? LOG_NOTICE : LOG_DEBUG; } + if( attr->priority & LOG_CONSOLE ) { + echo_to_console = true; + attr->priority &= ~LOG_CONSOLE; + } + if (!(LOG_MASK(attr->priority) & internal_mask_pri)) { return; } Modified: trunk/launchd/src/launchd_runtime.h =================================================================== --- trunk/launchd/src/launchd_runtime.h 2009-04-30 23:34:49 UTC (rev 23915) +++ trunk/launchd/src/launchd_runtime.h 2009-05-01 17:47:54 UTC (rev 23916) @@ -153,7 +153,6 @@ #define LOG_APPLEONLY 0x4141504c /* AAPL in hex */ #define LOG_SCOLDING 0x3030493b #define LOG_CONSOLE (1 << 31) -#define LOG_CONSOLE_FORCE (1 << 30) struct runtime_syslog_attr { const char *from_name; @@ -168,7 +167,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, bool log_to_console, const char *message, va_list args) __attribute__((format(printf, 3, 0))); +void runtime_vsyslog(struct runtime_syslog_attr *attr, const char *message, va_list args) __attribute__((format(printf, 2, 0))); void runtime_log_push(void); int64_t runtime_get_wall_time(void) __attribute__((warn_unused_result)); -------------- next part -------------- An HTML attachment was scrubbed... URL: From source_changes at macosforge.org Fri May 1 14:54:48 2009 From: source_changes at macosforge.org (source_changes at macosforge.org) Date: Fri, 1 May 2009 14:54:48 -0700 (PDT) Subject: [launchd-changes] [23917] tags/launchd-323/ Message-ID: <20090501215448.AE44E16E3C4E@beta.macosforge.org> Revision: 23917 http://trac.macosforge.org/projects/launchd/changeset/23917 Author: dsorresso at apple.com Date: 2009-05-01 14:54:48 -0700 (Fri, 01 May 2009) Log Message: ----------- "Tagging launchd-323 from https://svn.macosforge.org/repository/launchd/trunk" Added Paths: ----------- tags/launchd-323/ Property changes on: tags/launchd-323 ___________________________________________________________________ Added: svn:ignore + build Added: svn:mergeinfo + /branches/PR-5092682:23731-23742 /branches/PR-5898404:23681-23700 /branches/PR-5978442:23651-23701 /branches/PR-6132016:23719-23738 /branches/PR-6271234:23818-23822 /branches/PR-6562592:23812-23822 /branches/PR-6564965:23832-23851 /branches/PR-6589133:23810-23822 /branches/PR-6609410:23828 -------------- next part -------------- An HTML attachment was scrubbed... URL: From source_changes at macosforge.org Fri May 1 18:13:23 2009 From: source_changes at macosforge.org (source_changes at macosforge.org) Date: Fri, 1 May 2009 18:13:23 -0700 (PDT) Subject: [launchd-changes] [23918] trunk/launchd/src Message-ID: <20090502011323.A354116E6B6F@beta.macosforge.org> Revision: 23918 http://trac.macosforge.org/projects/launchd/changeset/23918 Author: dsorresso at apple.com Date: 2009-05-01 18:13:22 -0700 (Fri, 01 May 2009) Log Message: ----------- STD:VSC: /tset/POSIX.upe/ps/ps.ex 814 Failed Modified Paths: -------------- trunk/launchd/src/launchd.c trunk/launchd/src/launchd_core_logic.c Modified: trunk/launchd/src/launchd.c =================================================================== --- trunk/launchd/src/launchd.c 2009-05-01 21:54:48 UTC (rev 23917) +++ trunk/launchd/src/launchd.c 2009-05-02 01:13:22 UTC (rev 23918) @@ -125,13 +125,12 @@ int main(int argc, char *const *argv) { - const char *stdouterr_path = low_level_debug ? _PATH_CONSOLE : _PATH_DEVNULL; bool sflag = false; int ch; testfd_or_openfd(STDIN_FILENO, _PATH_DEVNULL, O_RDONLY); - testfd_or_openfd(STDOUT_FILENO, stdouterr_path, O_WRONLY); - testfd_or_openfd(STDERR_FILENO, stdouterr_path, O_WRONLY); + testfd_or_openfd(STDOUT_FILENO, _PATH_DEVNULL, O_WRONLY); + testfd_or_openfd(STDERR_FILENO, _PATH_DEVNULL, O_WRONLY); if (pid1_magic && g_use_gmalloc) { if (!getenv("DYLD_INSERT_LIBRARIES")) { @@ -162,10 +161,12 @@ launchd_runtime_init(); if( pid1_magic ) { - if( low_level_debug ) { - g_console = stdout; - } else if( launchd_assumes((g_console = fopen(_PATH_CONSOLE, "w")) != NULL) ) { - _fd(fileno(g_console)); + int cfd = -1; + if( launchd_assumes((cfd = open(_PATH_CONSOLE, O_WRONLY | O_NOCTTY)) != -1) ) { + _fd(cfd); + if( !launchd_assumes((g_console = fdopen(cfd, "w")) != NULL) ) { + close(cfd); + } } } Modified: trunk/launchd/src/launchd_core_logic.c =================================================================== --- trunk/launchd/src/launchd_core_logic.c 2009-05-01 21:54:48 UTC (rev 23917) +++ trunk/launchd/src/launchd_core_logic.c 2009-05-02 01:13:22 UTC (rev 23918) @@ -3501,21 +3501,12 @@ } } else if( pid1_magic && g_console && kev->ident == (uintptr_t)fileno(g_console) ) { int cfd = -1; - if( low_level_debug ) { - if( jobmgr_assumes(jm, (stdout = freopen(_PATH_CONSOLE, "w", stdout)) != NULL) ) { - cfd = fileno(stdout); + if( launchd_assumes((cfd = open(_PATH_CONSOLE, O_WRONLY | O_NOCTTY)) != -1) ) { + _fd(cfd); + if( !launchd_assumes((g_console = fdopen(cfd, "w")) != NULL) ) { + close(cfd); } - g_console = stdout; - } else { - if( jobmgr_assumes(jm, (g_console = freopen(_PATH_CONSOLE, "w", g_console)) != NULL) ) { - cfd = fileno(g_console); - } } - - if( cfd != -1 ) { - jobmgr_assumes(jm, kevent_mod((uintptr_t)cfd, EVFILT_VNODE, EV_ADD | EV_ONESHOT, NOTE_REVOKE, 0, jm) != -1); - _fd(cfd); - } } break; default: -------------- next part -------------- An HTML attachment was scrubbed... URL: From source_changes at macosforge.org Fri May 1 20:04:04 2009 From: source_changes at macosforge.org (source_changes at macosforge.org) Date: Fri, 1 May 2009 20:04:04 -0700 (PDT) Subject: [launchd-changes] [23919] tags/launchd-324/ Message-ID: <20090502030404.BF6E316E76C5@beta.macosforge.org> Revision: 23919 http://trac.macosforge.org/projects/launchd/changeset/23919 Author: dsorresso at apple.com Date: 2009-05-01 20:04:04 -0700 (Fri, 01 May 2009) Log Message: ----------- "Tagging launchd-324 from https://svn.macosforge.org/repository/launchd/trunk" Added Paths: ----------- tags/launchd-324/ Property changes on: tags/launchd-324 ___________________________________________________________________ Added: svn:ignore + build Added: svn:mergeinfo + /branches/PR-5092682:23731-23742 /branches/PR-5898404:23681-23700 /branches/PR-5978442:23651-23701 /branches/PR-6132016:23719-23738 /branches/PR-6271234:23818-23822 /branches/PR-6562592:23812-23822 /branches/PR-6564965:23832-23851 /branches/PR-6589133:23810-23822 /branches/PR-6609410:23828 -------------- next part -------------- An HTML attachment was scrubbed... URL: From source_changes at macosforge.org Sat May 9 14:26:35 2009 From: source_changes at macosforge.org (source_changes at macosforge.org) Date: Sat, 9 May 2009 14:26:35 -0700 (PDT) Subject: [launchd-changes] [23920] trunk/launchd/src/launchctl.c Message-ID: <20090509212635.B64B3180AE44@beta.macosforge.org> Revision: 23920 http://trac.macosforge.org/projects/launchd/changeset/23920 Author: dsorresso at apple.com Date: 2009-05-09 14:26:34 -0700 (Sat, 09 May 2009) Log Message: ----------- More for launchd should pass -1 to listen(2)'s backlog argument to respect Server's increased backlog. Modified Paths: -------------- trunk/launchd/src/launchctl.c Modified: trunk/launchd/src/launchctl.c =================================================================== --- trunk/launchd/src/launchctl.c 2009-05-02 03:04:04 UTC (rev 23919) +++ trunk/launchd/src/launchctl.c 2009-05-09 21:26:34 UTC (rev 23920) @@ -1299,7 +1299,7 @@ if (mgroup) { do_mgroup_join(sfd, res->ai_family, res->ai_socktype, res->ai_protocol, mgroup); } - if ((res->ai_socktype == SOCK_STREAM || res->ai_socktype == SOCK_SEQPACKET) && listen(sfd, SOMAXCONN) == -1) { + if ((res->ai_socktype == SOCK_STREAM || res->ai_socktype == SOCK_SEQPACKET) && listen(sfd, -1) == -1) { fprintf(stderr, "listen(): %s\n", strerror(errno)); return; } -------------- next part -------------- An HTML attachment was scrubbed... URL: From source_changes at macosforge.org Mon May 11 13:03:06 2009 From: source_changes at macosforge.org (source_changes at macosforge.org) Date: Mon, 11 May 2009 13:03:06 -0700 (PDT) Subject: [launchd-changes] [23921] trunk/launchd/src/launchd_unix_ipc.c Message-ID: <20090511200308.75CDB18A885A@beta.macosforge.org> Revision: 23921 http://trac.macosforge.org/projects/launchd/changeset/23921 Author: dsorresso at apple.com Date: 2009-05-11 13:03:00 -0700 (Mon, 11 May 2009) Log Message: ----------- `launchctl start` sometimes reports a failure despite succeeding Modified Paths: -------------- trunk/launchd/src/launchd_unix_ipc.c Modified: trunk/launchd/src/launchd_unix_ipc.c =================================================================== --- trunk/launchd/src/launchd_unix_ipc.c 2009-05-09 21:26:34 UTC (rev 23920) +++ trunk/launchd/src/launchd_unix_ipc.c 2009-05-11 20:03:00 UTC (rev 23921) @@ -396,8 +396,7 @@ } else { if (!strcmp(cmd, LAUNCH_KEY_STARTJOB)) { if ((j = job_find(launch_data_get_string(data))) != NULL) { - errno = 0; - job_dispatch(j, true); + errno = job_dispatch(j, true) ? 0 : errno; } resp = launch_data_new_errno(errno); } else if (!strcmp(cmd, LAUNCH_KEY_STOPJOB)) { -------------- next part -------------- An HTML attachment was scrubbed... URL: From source_changes at macosforge.org Mon May 11 14:29:43 2009 From: source_changes at macosforge.org (source_changes at macosforge.org) Date: Mon, 11 May 2009 14:29:43 -0700 (PDT) Subject: [launchd-changes] [23922] tags/launchd-325/ Message-ID: <20090511212943.9242818A9CF0@beta.macosforge.org> Revision: 23922 http://trac.macosforge.org/projects/launchd/changeset/23922 Author: dsorresso at apple.com Date: 2009-05-11 14:29:43 -0700 (Mon, 11 May 2009) Log Message: ----------- "Tagging launchd-325 from https://svn.macosforge.org/repository/launchd/trunk" Added Paths: ----------- tags/launchd-325/ Property changes on: tags/launchd-325 ___________________________________________________________________ Added: svn:ignore + build Added: svn:mergeinfo + /branches/PR-5092682:23731-23742 /branches/PR-5898404:23681-23700 /branches/PR-5978442:23651-23701 /branches/PR-6132016:23719-23738 /branches/PR-6271234:23818-23822 /branches/PR-6562592:23812-23822 /branches/PR-6564965:23832-23851 /branches/PR-6589133:23810-23822 /branches/PR-6609410:23828 -------------- next part -------------- An HTML attachment was scrubbed... URL: From source_changes at macosforge.org Wed May 27 09:51:04 2009 From: source_changes at macosforge.org (source_changes at macosforge.org) Date: Wed, 27 May 2009 09:51:04 -0700 (PDT) Subject: [launchd-changes] [23923] branches/SULeopard/launchd/src/launchd_core_logic.c Message-ID: <20090527165104.CF61E1C76AF1@beta.macosforge.org> Revision: 23923 http://trac.macosforge.org/projects/launchd/changeset/23923 Author: dsorresso at apple.com Date: 2009-05-27 09:51:04 -0700 (Wed, 27 May 2009) Log Message: ----------- Modified Paths: -------------- branches/SULeopard/launchd/src/launchd_core_logic.c Modified: branches/SULeopard/launchd/src/launchd_core_logic.c =================================================================== --- branches/SULeopard/launchd/src/launchd_core_logic.c 2009-05-11 21:29:43 UTC (rev 23922) +++ branches/SULeopard/launchd/src/launchd_core_logic.c 2009-05-27 16:51:04 UTC (rev 23923) @@ -2653,6 +2653,8 @@ job_assumes(j, runtime_close(oepair[1]) != -1); j->log_redirect_fd = 0; } + job_assumes(j, kevent_mod((uintptr_t)j, EVFILT_TIMER, EV_ADD|EV_ONESHOT, NOTE_SECONDS, 1, j) != -1); + job_ignore(j); break; case 0: if (_vproc_post_fork_ping()) { -------------- next part -------------- An HTML attachment was scrubbed... URL: