Changeset 23040
- Timestamp:
- 02/07/07 15:39:58 (22 months ago)
- Location:
- trunk/launchd/src
- Files:
-
- 3 modified
-
launchd.plist.5 (modified) (1 diff)
-
launchd_core_logic.c (modified) (12 diffs)
-
liblaunch_public.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/launchd/src/launchd.plist.5
r23033 r23040 177 177 .Nm launchd 178 178 for use by the job at check in time. 179 .It Sy ExitTimeOut <integer> 180 The amount of time 181 .Nm launchd 182 waits before sending a SIGKILL signal. The default value is 20 seconds. The value zero is interpreted as infinity. 179 183 .It Sy ThrottleInterval <integer> 180 184 This key lets one override the default throttling policy imposed on jobs by -
trunk/launchd/src/launchd_core_logic.c
r23038 r23040 88 88 #define LAUNCHD_MIN_JOB_RUN_TIME 10 89 89 #define LAUNCHD_ADVISABLE_IDLE_TIMEOUT 30 90 #define LAUNCHD_DEFAULT_EXIT_TIMEOUT 20 90 91 91 92 extern char **environ; … … 255 256 int log_redirect_fd; 256 257 int nice; 257 int timeout; 258 unsigned int timeout; 259 unsigned int exit_timeout; 258 260 int stdout_err_fd; 261 struct timeval sent_sigterm_time; 259 262 time_t start_time; 260 263 time_t min_run_time; … … 406 409 if (j->p) { 407 410 job_assumes(j, kill(j->p, SIGTERM) != -1); 411 job_assumes(j, gettimeofday(&j->sent_sigterm_time, NULL) != -1); 412 if (j->exit_timeout) { 413 job_assumes(j, kevent_mod((uintptr_t)&j->exit_timeout, EVFILT_TIMER, 414 EV_ADD|EV_ONESHOT, NOTE_SECONDS, j->exit_timeout, j) != -1); 415 } 408 416 } 409 417 } … … 517 525 job_remove(ji); 518 526 } else { 519 if (debug_shutdown_hangs) {520 job_assumes(ji, kevent_mod((uintptr_t)ji, EVFILT_TIMER, EV_ADD|EV_ONESHOT, NOTE_SECONDS, 8, ji) != -1);521 }522 527 job_stop(ji); 523 528 } … … 663 668 job_assumes(j, kevent_mod((uintptr_t)&j->start_interval, EVFILT_TIMER, EV_DELETE, 0, 0, NULL) != -1); 664 669 } 670 if (j->exit_timeout) { 671 kevent_mod((uintptr_t)&j->exit_timeout, EVFILT_TIMER, EV_DELETE, 0, 0, NULL); 672 } 665 673 666 674 kevent_mod((uintptr_t)j, EVFILT_TIMER, EV_DELETE, 0, 0, NULL); … … 908 916 j->min_run_time = LAUNCHD_MIN_JOB_RUN_TIME; 909 917 j->timeout = LAUNCHD_ADVISABLE_IDLE_TIMEOUT; 918 j->exit_timeout = LAUNCHD_DEFAULT_EXIT_TIMEOUT; 910 919 j->currently_ignored = true; 911 920 j->ondemand = true; … … 1163 1172 { 1164 1173 switch (key[0]) { 1174 case 'e': 1175 case 'E': 1176 if (strcasecmp(key, LAUNCH_JOBKEY_EXITTIMEOUT) == 0) { 1177 if (value < 0) { 1178 job_log(j, LOG_WARNING, "Exit timeout less zero. Ignoring."); 1179 } else { 1180 j->exit_timeout = value; 1181 } 1182 } 1183 break; 1165 1184 case 'n': 1166 1185 case 'N': … … 1578 1597 job_reap(job_t j) 1579 1598 { 1599 struct timeval tve, tvd; 1580 1600 struct rusage ru; 1581 1601 int status; … … 1596 1616 return; 1597 1617 } 1618 1619 job_assumes(j, gettimeofday(&tve, NULL) != -1); 1598 1620 1599 1621 if (j->wait_reply_port) { … … 1601 1623 job_assumes(j, job_mig_wait_reply(j->wait_reply_port, 0, status) == 0); 1602 1624 j->wait_reply_port = MACH_PORT_NULL; 1625 } 1626 1627 if (j->sent_sigterm_time.tv_sec) { 1628 double delta; 1629 1630 timersub(&tve, &j->sent_sigterm_time, &tvd); 1631 1632 delta = (double)tvd.tv_sec + (double)tvd.tv_usec / (double)1000000; 1633 1634 job_log(j, tvd.tv_sec ? LOG_NOTICE : LOG_INFO, "Exited %f seconds after SIGTERM was sent", delta); 1603 1635 } 1604 1636 … … 1725 1757 break; 1726 1758 case EVFILT_TIMER: 1727 if ((uintptr_t)j == kev->ident) { 1728 if (j->p && job_assumes(j, debug_shutdown_hangs)) { 1759 if ((uintptr_t)j == kev->ident || (uintptr_t)&j->start_interval == kev->ident) { 1760 job_dispatch(j, true); 1761 } else if ((uintptr_t)&j->exit_timeout == kev->ident) { 1762 if (debug_shutdown_hangs) { 1729 1763 job_force_sampletool(j); 1730 } else {1731 job_dispatch(j, true);1732 1764 } 1733 } else if ((uintptr_t)&j->start_interval == kev->ident) {1734 job_ dispatch(j, true);1765 job_log(j, LOG_WARNING, "Exit timeout elapsed (%u seconds). Killing.", j->exit_timeout); 1766 job_assumes(j, kill(j->p, SIGKILL) != -1); 1735 1767 } else { 1736 1768 calendarinterval_callback(j, kev); … … 1788 1820 1789 1821 job_log(j, LOG_DEBUG, "Starting"); 1822 1823 j->sent_sigterm_time.tv_sec = 0; 1824 j->sent_sigterm_time.tv_usec = 0; 1790 1825 1791 1826 /* FIXME, using stdinpath is a hack for re-reading the conf file */ -
trunk/launchd/src/liblaunch_public.h
r22994 r23040 59 59 #define LAUNCH_JOBKEY_GROUPNAME "GroupName" 60 60 #define LAUNCH_JOBKEY_TIMEOUT "TimeOut" 61 #define LAUNCH_JOBKEY_EXITTIMEOUT "ExitTimeOut" 61 62 #define LAUNCH_JOBKEY_INITGROUPS "InitGroups" 62 63 #define LAUNCH_JOBKEY_SOCKETS "Sockets"

