~vorlon/ubuntu/raring/upstart/lp.1199778

« back to all changes in this revision

Viewing changes to init/job.c

  • Committer: Scott James Remnant
  • Date: 2006-08-15 04:43:05 UTC
  • Revision ID: scott@netsplit.com-20060815044305-6df6aa1ebc6f419a
* init/job.c (job_handle_child): Respawn processes that were not
supposed to have died.
* init/tests/test_job.c (test_handle_child): Test the respawn code.

Show diffs side-by-side

added added

removed removed

Lines of Context:
738
738
 
739
739
        switch (job->state) {
740
740
        case JOB_RUNNING:
741
 
                /* FIXME check daemon; if true, check exit status
742
 
                 * and maybe don't change the goal */
 
741
                /* Check whether we should respawn the process
 
742
                 *
 
743
                 * If a list of "normal" exit codes is provided, this is
 
744
                 * the list of exit codes that _prevent_ a respawn
 
745
                 */
 
746
                if (job->respawn) {
 
747
                        size_t i;
 
748
 
 
749
                        for (i = 0; i < job->normalexit_len; i++)
 
750
                                if ((! killed) &&
 
751
                                    (job->normalexit[i] == status))
 
752
                                        break;
 
753
 
 
754
                        if (i == job->normalexit_len)
 
755
                                break;
 
756
                }
 
757
 
743
758
                job->goal = JOB_STOP;
744
759
                break;
745
760
        default:
 
761
                /* If a script is killed or exits with a status other than
 
762
                 * zero, it's considered a failure and prevents the process
 
763
                 * from starting.
 
764
                 */
746
765
                if (killed || status)
747
766
                        job->goal = JOB_STOP;
748
767