core: failure to spawn ExecStartPost should not run ExecStop
authorAlan Jenkins <alan.christopher.jenkins@gmail.com>
Mon, 14 Aug 2017 10:15:38 +0000 (11:15 +0100)
committerAlan Jenkins <alan.christopher.jenkins@gmail.com>
Wed, 1 Nov 2017 15:28:50 +0000 (15:28 +0000)
Failure to spawn ExecStartPost was being handled differently to e.g.
EXIT_FAILURE returned by ExecStartPost.  It looks like this was an
oversight.  Fix to match documented behaviour.

`man systemd.service`:

> Note that if any of the commands specified in ExecStartPre=, ExecStart=,
> or ExecStartPost= fail (and are not prefixed with "-", see above) or time
> out before the service is fully up, execution continues with commands
> specified in ExecStopPost=, the commands in ExecStop= are skipped.

src/core/service.c

index 915943a..78f315a 100644 (file)
@@ -2087,7 +2087,7 @@ static void service_run_next_control(Service *s) {
 fail:
         log_unit_warning_errno(UNIT(s), r, "Failed to run next control task: %m");
 
-        if (IN_SET(s->state, SERVICE_START_PRE, SERVICE_STOP))
+        if (IN_SET(s->state, SERVICE_START_PRE, SERVICE_START_POST, SERVICE_STOP))
                 service_enter_signal(s, SERVICE_STOP_SIGTERM, SERVICE_FAILURE_RESOURCES);
         else if (s->state == SERVICE_STOP_POST)
                 service_enter_dead(s, SERVICE_FAILURE_RESOURCES, true);