Changeset 23371
- Timestamp:
- 09/11/07 16:44:27 (15 months ago)
- Files:
-
- 1 modified
-
trunk/launchd/src/launchd_core_logic.c (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/launchd/src/launchd_core_logic.c
r23369 r23371 349 349 unsigned int exit_timeout; 350 350 int stdout_err_fd; 351 struct timevalsent_sigterm_time;351 uint64_t sent_sigterm_time; 352 352 uint64_t start_time; 353 353 uint32_t min_run_time; … … 448 448 static void extract_rcsid_substr(const char *i, char *o, size_t osz); 449 449 static void do_first_per_user_launchd_hack(void); 450 static void do_file_init(void) __attribute__((constructor)); 450 451 451 452 /* file local globals */ … … 454 455 static bool did_first_per_user_launchd_BootCache_hack; 455 456 static jobmgr_t background_jobmgr; 457 static mach_timebase_info_data_t tbi; 456 458 457 459 /* process wide globals */ … … 523 525 524 526 job_assumes(j, kill(j->p, SIGTERM) != -1); 525 j ob_assumes(j, gettimeofday(&j->sent_sigterm_time, NULL) != -1);527 j->sent_sigterm_time = mach_absolute_time(); 526 528 527 529 if (j->exit_timeout) { … … 1899 1901 job_reap(job_t j) 1900 1902 { 1901 struct timeval tve, tvd;1902 1903 struct rusage ru; 1903 1904 int status; … … 1944 1945 LIST_REMOVE(j, pid_hash_sle); 1945 1946 1946 job_assumes(j, gettimeofday(&tve, NULL) != -1);1947 1948 1947 if (j->wait_reply_port) { 1949 1948 job_log(j, LOG_DEBUG, "MPM wait reply being sent"); … … 1952 1951 } 1953 1952 1954 if (j->sent_sigterm_time.tv_sec) { 1955 timersub(&tve, &j->sent_sigterm_time, &tvd); 1956 1957 job_log(j, LOG_INFO, "Exited %ld.%06d seconds after %s was sent", 1958 tvd.tv_sec, tvd.tv_usec, signal_to_C_name(j->sent_sigkill ? SIGKILL : SIGTERM)); 1953 if (j->sent_sigterm_time) { 1954 uint64_t td_sec, td_usec, td = (mach_absolute_time() - j->sent_sigterm_time) * tbi.numer / tbi.denom; 1955 1956 td_sec = td / NSEC_PER_SEC; 1957 td_usec = (td % NSEC_PER_SEC) / NSEC_PER_USEC; 1958 1959 job_log(j, LOG_INFO, "Exited %lld.%06lld seconds after %s was sent", 1960 td_sec, td_usec, signal_to_C_name(j->sent_sigkill ? SIGKILL : SIGTERM)); 1959 1961 } 1960 1962 … … 2176 2178 } else if (&j->exit_timeout == ident) { 2177 2179 if (j->sent_sigkill) { 2178 struct timeval tvd, tve;2179 2180 job_assumes(j, gettimeofday(&tve, NULL) != -1);2181 t imersub(&tve, &j->sent_sigterm_time, &tvd);2182 tvd.tv_sec -= j->exit_timeout; 2183 job_log(j, LOG_ERR, "Did not die after sending SIGKILL %l u seconds ago...", tvd.tv_sec);2180 uint64_t td = (mach_absolute_time() - j->sent_sigterm_time) * tbi.numer / tbi.denom; 2181 2182 td /= NSEC_PER_SEC; 2183 td -= j->exit_timeout; 2184 2185 job_log(j, LOG_ERR, "Did not die after sending SIGKILL %llu seconds ago...", td); 2184 2186 } else { 2185 2187 job_force_sampletool(j); … … 2286 2288 job_start(job_t j) 2287 2289 { 2288 static mach_timebase_info_data_t tbi;2289 2290 uint64_t td, tnow = mach_absolute_time(); 2290 2291 int spair[2]; … … 2296 2297 u_int proc_fflags = /* NOTE_EXEC|NOTE_FORK| */ NOTE_EXIT /* |NOTE_REAP */; 2297 2298 2298 if (tbi.denom == 0) {2299 launchd_assert(mach_timebase_info(&tbi) == 0);2300 }2301 2302 2299 if (!job_assumes(j, j->mgr != NULL)) { 2303 2300 return; … … 2321 2318 } 2322 2319 2323 j->sent_sigterm_time.tv_sec = 0; 2324 j->sent_sigterm_time.tv_usec = 0; 2320 j->sent_sigterm_time = 0; 2325 2321 2326 2322 if (!j->legacy_mach_job) { … … 6325 6321 free(w4r); 6326 6322 } 6323 6324 void 6325 do_file_init(void) 6326 { 6327 launchd_assert(mach_timebase_info(&tbi) == 0); 6328 6329 }

