Only in upstart-1.2: Makefile Only in upstart-1.2/conf: Makefile Only in upstart-1.2: config.h Only in upstart-1.2: config.log Only in upstart-1.2: config.status Only in upstart-1.2/contrib: Makefile Only in upstart-1.2/dbus: Makefile Only in upstart-1.2/doc: Makefile Only in upstart-1.2/init: .deps Only in upstart-1.2/init: .job_process.c.swp Only in upstart-1.2/init: .libs Only in upstart-1.2/init: Makefile Only in upstart-1.2/init: blocked.o Only in upstart-1.2/init: com.ubuntu.Upstart.Instance.c Only in upstart-1.2/init: com.ubuntu.Upstart.Instance.h Only in upstart-1.2/init: com.ubuntu.Upstart.Instance.o Only in upstart-1.2/init: com.ubuntu.Upstart.Job.c Only in upstart-1.2/init: com.ubuntu.Upstart.Job.h Only in upstart-1.2/init: com.ubuntu.Upstart.Job.o Only in upstart-1.2/init: com.ubuntu.Upstart.c Only in upstart-1.2/init: com.ubuntu.Upstart.h Only in upstart-1.2/init: com.ubuntu.Upstart.o Only in upstart-1.2/init: conf.o Only in upstart-1.2/init: control.o Only in upstart-1.2/init: core Only in upstart-1.2/init: environ.o Only in upstart-1.2/init: event.o Only in upstart-1.2/init: event_operator.o Only in upstart-1.2/init: init Only in upstart-1.2/init: job.o Only in upstart-1.2/init: job_class.o diff -rup upstart-1.2~/init/job_process.c upstart-1.2/init/job_process.c --- upstart-1.2~/init/job_process.c 2011-03-22 10:18:00.000000000 -0700 +++ upstart-1.2/init/job_process.c 2012-11-28 17:10:43.473432706 -0800 @@ -1077,8 +1077,8 @@ job_process_terminated (Job *job * For services that can be respawned, a zero exit status is * also a failure unless listed. */ - if (status || (job->class->respawn && (! job->class->task))) - { + if ((status || (job->class->respawn && (! job->class->task))) + && (job->goal == JOB_START)) { failed = TRUE; for (size_t i = 0; i < job->class->normalexit_len; i++) { if (job->class->normalexit[i] == status) { Only in upstart-1.2/init: job_process.o Only in upstart-1.2/init: main.o Only in upstart-1.2/init: parse_conf.o Only in upstart-1.2/init: parse_job.o Only in upstart-1.2/init: process.o Only in upstart-1.2/init: system.o Only in upstart-1.2/init: test_blocked Only in upstart-1.2/init: test_blocked.o Only in upstart-1.2/init: test_conf Only in upstart-1.2/init: test_conf.o Only in upstart-1.2/init: test_control Only in upstart-1.2/init: test_control.o Only in upstart-1.2/init: test_environ Only in upstart-1.2/init: test_environ.o Only in upstart-1.2/init: test_event Only in upstart-1.2/init: test_event.o Only in upstart-1.2/init: test_event_operator Only in upstart-1.2/init: test_event_operator.o Only in upstart-1.2/init: test_job Only in upstart-1.2/init: test_job.o Only in upstart-1.2/init: test_job_class Only in upstart-1.2/init: test_job_class.o Only in upstart-1.2/init: test_job_process Only in upstart-1.2/init: test_job_process.o Only in upstart-1.2/init: test_parse_conf Only in upstart-1.2/init: test_parse_conf.o Only in upstart-1.2/init: test_parse_job Only in upstart-1.2/init: test_parse_job.o Only in upstart-1.2/init: test_process Only in upstart-1.2/init: test_process.o Only in upstart-1.2/init: test_system Only in upstart-1.2/init: test_system.o Only in upstart-1.2/init/tests: .test_job_process.c.swp diff -rup upstart-1.2~/init/tests/test_job_process.c upstart-1.2/init/tests/test_job_process.c --- upstart-1.2~/init/tests/test_job_process.c 2011-03-16 15:17:44.000000000 -0700 +++ upstart-1.2/init/tests/test_job_process.c 2012-11-28 17:11:02.483458521 -0800 @@ -3424,6 +3424,109 @@ test_handler (void) class->respawn = FALSE; + /* Check that we don't respawn the job if the running process exits + * before the pre-stop process finishes if we were going to stop the + * running proecss anyway. + */ + TEST_FEATURE ("with respawn of to be stopped while pre-stop process"); + class->respawn = TRUE; + class->respawn_limit = 5; + class->respawn_interval = 10; + + class->process[PROCESS_PRE_STOP] = process_new (class); + class->process[PROCESS_PRE_STOP]->command = "echo"; + + TEST_ALLOC_FAIL { + TEST_ALLOC_SAFE { + job = job_new (class, ""); + + blocked = blocked_new (job, BLOCKED_EVENT, event); + event_block (event); + nih_list_add (&job->blocking, &blocked->entry); + } + + job->goal = JOB_STOP; + job->state = JOB_PRE_STOP; + job->pid[PROCESS_MAIN] = 1; + job->pid[PROCESS_PRE_STOP] = 2; + + TEST_FREE_TAG (blocked); + + job->blocker = NULL; + event->failed = FALSE; + + job->failed = FALSE; + job->failed_process = -1; + job->exit_status = 0; + + TEST_DIVERT_STDERR (output) { + job_process_handler (NULL, 1, NIH_CHILD_EXITED, 0); + } + rewind (output); + + TEST_EQ (job->goal, JOB_STOP); + TEST_EQ (job->state, JOB_PRE_STOP); + TEST_EQ (job->pid[PROCESS_MAIN], 0); + TEST_EQ (job->pid[PROCESS_PRE_STOP], 2); + + TEST_EQ (event->blockers, 1); + TEST_EQ (event->failed, FALSE); + + TEST_EQ_P (job->blocker, NULL); + + TEST_LIST_NOT_EMPTY (&job->blocking); + TEST_NOT_FREE (blocked); + TEST_EQ_P (blocked->event, event); + + TEST_EQ (job->failed, FALSE); + TEST_EQ (job->failed_process, (ProcessType)-1); + TEST_EQ (job->exit_status, 0); + + job_process_handler (NULL, 2, NIH_CHILD_EXITED, 0); + + TEST_EQ (job->goal, JOB_STOP); + TEST_EQ (job->state, JOB_STOPPING); + TEST_EQ (job->pid[PROCESS_MAIN], 0); + TEST_EQ (job->pid[PROCESS_PRE_STOP], 0); + + TEST_EQ (job->respawn_count, 0); + + TEST_EQ (event->blockers, 1); + TEST_EQ (event->failed, FALSE); + + TEST_LIST_NOT_EMPTY (&job->blocking); + TEST_NOT_FREE (blocked); + TEST_EQ_P (blocked->event, event); + event_unblock (event); + + TEST_NE_P (job->blocker, NULL); + + TEST_LIST_NOT_EMPTY (&job->blocker->blocking); + + blocked = (Blocked *)job->blocker->blocking.next; + TEST_ALLOC_SIZE (blocked, sizeof (Blocked)); + TEST_ALLOC_PARENT (blocked, job->blocker); + TEST_EQ (blocked->type, BLOCKED_JOB); + TEST_EQ_P (blocked->job, job); + nih_free (blocked); + + TEST_LIST_EMPTY (&job->blocker->blocking); + + TEST_EQ (job->failed, FALSE); + TEST_EQ (job->failed_process, (ProcessType)-1); + TEST_EQ (job->exit_status, 0); + + TEST_FILE_END (output); + TEST_FILE_RESET (output); + + nih_free (job); + } + + nih_free (class->process[PROCESS_PRE_STOP]); + class->process[PROCESS_PRE_STOP] = NULL; + + class->respawn = FALSE; + /* Check that a running task that exits while we're waiting for * the stopping event to finish does not change the state or * record the exit information since we were stopping anyway and Only in upstart-1.2/intl: Makefile Only in upstart-1.2: libtool Only in upstart-1.2/po: Makefile Only in upstart-1.2/po: Makefile.in Only in upstart-1.2/po: POTFILES Only in upstart-1.2: stamp-h1 Only in upstart-1.2/util: .deps Only in upstart-1.2/util: .libs Only in upstart-1.2/util: Makefile Only in upstart-1.2/util: com.ubuntu.Upstart.Instance.c Only in upstart-1.2/util: com.ubuntu.Upstart.Instance.h Only in upstart-1.2/util: com.ubuntu.Upstart.Instance.o Only in upstart-1.2/util: com.ubuntu.Upstart.Job.c Only in upstart-1.2/util: com.ubuntu.Upstart.Job.h Only in upstart-1.2/util: com.ubuntu.Upstart.Job.o Only in upstart-1.2/util: com.ubuntu.Upstart.c Only in upstart-1.2/util: com.ubuntu.Upstart.h Only in upstart-1.2/util: com.ubuntu.Upstart.o Only in upstart-1.2/util: initctl Only in upstart-1.2/util: initctl.o Only in upstart-1.2/util: reboot Only in upstart-1.2/util: reboot.o Only in upstart-1.2/util: runlevel Only in upstart-1.2/util: runlevel.o Only in upstart-1.2/util: shutdown Only in upstart-1.2/util: shutdown.o Only in upstart-1.2/util: sysv.o Only in upstart-1.2/util: telinit Only in upstart-1.2/util: telinit.o Only in upstart-1.2/util: test_initctl Only in upstart-1.2/util: test_initctl-initctl.o Only in upstart-1.2/util: test_initctl-test_initctl.o Only in upstart-1.2/util: test_sysv Only in upstart-1.2/util: test_sysv.o Only in upstart-1.2/util: test_telinit Only in upstart-1.2/util: test_telinit-telinit.o Only in upstart-1.2/util: test_telinit-test_telinit.o Only in upstart-1.2/util: test_utmp Only in upstart-1.2/util: test_utmp.o Only in upstart-1.2/util: utmp.o