Projects
Browse Source     Search     Timeline     Wiki

Changeset 23039

Show
Ignore:
Timestamp:
02/07/07 13:07:49 (22 months ago)
Author:
zarzycki@…
Message:

Clean up. Now if we can properly make our reflector threads go away, we should be able to go to single user mode again. :-)

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/launchd/src/launchd.c

    r23025 r23039  
    301301         */ 
    302302        if (!h && stat(ldconf, &sb) == 0) { 
    303                 job_dispatch(rlcj, true); 
     303                rlcj = job_dispatch(rlcj, true); 
    304304        } 
    305305 
    306306        if (fbj) { 
    307                 job_dispatch(fbj, true); 
     307                fbj = job_dispatch(fbj, true); 
    308308        } 
    309309 
     
    475475launchd_single_user(void) 
    476476{ 
    477         int tries; 
     477        syslog(LOG_NOTICE, "Going to single-user mode"); 
     478 
     479        re_exec_in_single_user_mode = true; 
    478480 
    479481        launchd_shutdown(); 
    480482 
    481         kill(-1, SIGTERM); 
    482  
    483         for (tries = 0; tries < 10; tries++) { 
    484                 sleep(1); 
    485                 if (kill(-1, 0) == -1 && errno == ESRCH) { 
    486                         goto out; 
    487                 } 
    488         } 
    489  
    490         syslog(LOG_WARNING, "Gave up waiting for processes to exit while going to single user mode, sending SIGKILL"); 
     483        sleep(3); 
     484 
    491485        kill(-1, SIGKILL); 
    492  
    493 out: 
    494         re_exec_in_single_user_mode = true; 
    495486} 
    496487 
     
    502493        case SIGHUP: 
    503494                if (rlcj) { 
    504                         job_dispatch(rlcj, true); 
     495                        rlcj = job_dispatch(rlcj, true); 
    505496                } 
    506497                break; 
     
    692683                } else if (re_exec_in_single_user_mode) { 
    693684                        re_exec_in_single_user_mode = false; 
     685                        kill(-1, SIGKILL); /* One last time, just to clear the room */ 
    694686                        launchd_assumes(execl("/sbin/launchd", "/sbin/launchd", "-s", NULL) != -1); 
    695687                }