Changeset 23046
- Timestamp:
- 02/08/07 14:39:50 (22 months ago)
- Location:
- trunk/launchd/src
- Files:
-
- 2 modified
-
launchd_core_logic.c (modified) (7 diffs)
-
launchd_runtime.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/launchd/src/launchd_core_logic.c
r23045 r23046 517 517 job_t ji, jn; 518 518 519 jobmgr_log(jm, LOG_DEBUG, "Beginning job manager shutdown"); 520 519 521 SLIST_FOREACH_SAFE(jmi, &jm->submgrs, sle, jmn) { 520 522 jobmgr_shutdown(jmi); … … 540 542 job_t ji; 541 543 542 while ((jmi = SLIST_FIRST(&jm->submgrs))) { 543 jobmgr_remove(jmi); 544 } 544 jobmgr_log(jm, LOG_DEBUG, "Removed job manager"); 545 546 if (!jobmgr_assumes(jm, SLIST_EMPTY(&jm->submgrs))) { 547 while ((jmi = SLIST_FIRST(&jm->submgrs))) { 548 jobmgr_remove(jmi); 549 } 550 } 551 552 /* We should have one job left and it should be the anonymous job */ 553 ji = SLIST_FIRST(&jm->jobs); 554 jobmgr_assumes(jm, ji && ji == jm->anonj && (SLIST_NEXT(ji, sle) == NULL)); 545 555 546 556 while ((ji = SLIST_FIRST(&jm->jobs))) { 547 557 job_remove(ji); 548 }549 550 if (jm->parentmgr) {551 SLIST_REMOVE(&jm->parentmgr->submgrs, jm, jobmgr_s, sle);552 558 } 553 559 … … 570 576 if (jm->jm_stderr) { 571 577 free(jm->jm_stderr); 578 } 579 580 if (jm->parentmgr) { 581 SLIST_REMOVE(&jm->parentmgr->submgrs, jm, jobmgr_s, sle); 582 jobmgr_tickle(jm->parentmgr); 572 583 } 573 584 … … 591 602 } 592 603 593 if (j->p && !j->anonymous) { 594 if (kevent_mod(j->p, EVFILT_PROC, EV_ADD, NOTE_EXIT, 0, &kqsimple_zombie_reaper) == -1) { 595 job_reap(j); 596 } else { 597 /* we've attached the simple zombie reaper, we're going to delete the job before it is dead */ 598 job_stop(j); 599 } 600 } 601 602 if (j->forkfd) { 604 if (!job_assumes(j, j->p == 0)) { 605 job_assumes(j, kill(j->p, SIGKILL) != -1); 606 job_reap(j); 607 } 608 609 if (!job_assumes(j, j->forkfd == 0)) { 603 610 job_assumes(j, close(j->forkfd) != -1); 604 611 } 605 612 606 if ( j->log_redirect_fd) {613 if (!job_assumes(j, j->log_redirect_fd == 0)) { 607 614 job_assumes(j, close(j->log_redirect_fd) != -1); 608 615 } … … 2804 2811 return true; 2805 2812 } else if (j->mgr->shutting_down) { 2806 job_log(j, LOG_INFO, "Exited while shutdown in progress."); 2813 unsigned int cnt = 0; 2814 job_t ji; 2815 2816 SLIST_FOREACH(ji, &j->mgr->jobs, sle) { 2817 if (ji->p) { 2818 cnt++; 2819 } 2820 } 2821 2822 job_log(j, LOG_INFO, "Exited while shutdown in progress. Processes remaining: %u", cnt); 2807 2823 return true; 2808 2824 } else if (!j->checkedin && (!SLIST_EMPTY(&j->sockets) || !SLIST_EMPTY(&j->machservices))) { … … 3194 3210 job_t ji; 3195 3211 3212 if (!SLIST_EMPTY(&jm->submgrs)) { 3213 return false; 3214 } 3215 3196 3216 SLIST_FOREACH(ji, &jm->jobs, sle) { 3197 3217 if (ji->p) { … … 3320 3340 3321 3341 jobmgr_assumes(jmr, jmr->anonj != NULL); 3342 3343 jobmgr_log(jmr, LOG_DEBUG, "Created job manager"); 3322 3344 3323 3345 return jmr; -
trunk/launchd/src/launchd_runtime.c
r23032 r23046 36 36 #include <mach/exception.h> 37 37 #include <sys/types.h> 38 #include <sys/stat.h> 38 39 #include <sys/time.h> 39 40 #include <sys/event.h> … … 579 580 /* XXX - So very gross */ 580 581 if (gc_this_jobmgr) { 581 jobmgr_ remove(gc_this_jobmgr);582 jobmgr_shutdown(gc_this_jobmgr); 582 583 gc_this_jobmgr = NULL; 583 584 } … … 675 676 676 677 if (ourlogfile == NULL) { 678 rename("/var/log/launchd_raw.log", "/var/log/launchd_raw-old.log"); 677 679 ourlogfile = fopen("/var/log/launchd_raw.log", "a"); 680 chmod("/var/log/launchd_raw.log", DEFFILEMODE); 678 681 } 679 682

