init: pre-stop not run when no main process

Reported by Scott James Remnant (Canonical) on 2008-07-29
26
This bug affects 5 people
Affects Status Importance Assigned to Milestone
upstart
Low
Unassigned

Bug Description

The check for whether to run pre-stop relies on there being a main process defined, which is arguably a bug. We really care about the reason we were stopped.

Changed in upstart:
importance: Undecided → Low
status: New → Confirmed
Changed in upstart:
milestone: none → 0.10
keesj (keesj) wrote :

I don't understand the comments. Overall I agree that pre-stop should only run to "stop" the process.
but what is the relation with the "stop reason" ?

As in pre-stop should be run if the reason for the stop is a manual command or event.

Whereas right now the pre-stop should be run if there is a main process pid ;)

Changed in upstart:
milestone: 0.10 → none
summary: - pre-stop not run when no main process
+ init: pre-stop not run when no main process
Changed in upstart:
status: Confirmed → Triaged
Numérigraphe (numerigraphe) wrote :

If this is not fixed yet, then it's a problem for "state" jobs that have no PID at all (no exec or script stanza).
Lionel Sausin.

Clint Byrum (clint-fewbar) wrote :

Numerigraphe, it still seems to be the case.

Its somewhat confusing in job_next_state why so much trouble is taken to skip to JOB_STOPPING if there is no main process:

    case JOB_RUNNING:
        switch (job->goal) {
        case JOB_STOP:
            if (job->class->process[PROCESS_MAIN]
                && (job->pid[PROCESS_MAIN] > 0)) {
                return JOB_PRE_STOP;
            } else {
                return JOB_STOPPING;
            }
        case JOB_START:
            return JOB_STOPPING;
        default:
            nih_assert_not_reached ();
        }

Seems it would be simpler to just go to pre-stop no matter what. I'm sure there's a good reason for this though.

Tomer Chachamu (r3m0t) wrote :

If you are suffering this, you can add this to your job configuration:

script
    # we need this section so that pre-stop gets run!
    # https://bugs.launchpad.net/upstart/+bug/252996
    while true
        do sleep 1d
    done
end script

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers