]> err.no Git - systemd/commitdiff
implement service type 'finish'
authorLennart Poettering <lennart@poettering.net>
Sat, 30 Jan 2010 01:07:35 +0000 (02:07 +0100)
committerLennart Poettering <lennart@poettering.net>
Sat, 30 Jan 2010 01:07:35 +0000 (02:07 +0100)
execute.h
service.c

index fff54b120e62fc80badc3b1411b5e67ffb478a9f..51c2c0076085f50380a883755159b83d4dc306b1 100644 (file)
--- a/execute.h
+++ b/execute.h
@@ -102,7 +102,6 @@ typedef enum ExitStatus {
         /* The LSB suggests that error codes >= 200 are "reserved". We
          * use them here under the assumption that they hence are
          * unused by init scripts.
-         * c->
          *
          * http://refspecs.freestandards.org/LSB_3.1.0/LSB-Core-generic/LSB-Core-generic/iniscrptact.html */
 
index b564c986b96dc2d872a565c450119903383baffd..46066329f4415b1f0291a151c417ffad0a43f7fb 100644 (file)
--- a/service.c
+++ b/service.c
@@ -262,7 +262,8 @@ static void service_set_state(Service *s, ServiceState state) {
             state != SERVICE_AUTO_RESTART)
                 unit_unwatch_timer(UNIT(s), &s->timer_watch);
 
-        if (state != SERVICE_START_POST &&
+        if (state != SERVICE_START &&
+            state != SERVICE_START_POST &&
             state != SERVICE_RUNNING &&
             state != SERVICE_RELOAD &&
             state != SERVICE_STOP &&
@@ -590,6 +591,13 @@ static void service_enter_start(Service *s) {
 
                 s->control_pid = pid;
                 s->control_command = s->exec_command[SERVICE_EXEC_START];
+        } else if (s->type == SERVICE_FINISH) {
+
+                /* For finishing services we wait until the start
+                 * process exited, too, but it is our main process. */
+
+                s->main_pid = pid;
+                s->control_command = s->exec_command[SERVICE_EXEC_START];
         } else
                 assert_not_reached("Unknown service type");
 
@@ -806,7 +814,7 @@ static void service_sigchld_event(Unit *u, pid_t pid, int code, int status) {
                 exec_status_fill(&s->main_exec_status, pid, code, status);
                 s->main_pid = 0;
 
-                if (s->type == SERVICE_SIMPLE) {
+                if (s->type == SERVICE_SIMPLE || s->type == SERVICE_FINISH) {
                         assert(s->exec_command[SERVICE_EXEC_START]);
                         s->exec_command[SERVICE_EXEC_START]->exec_status = s->main_exec_status;
                 }
@@ -825,6 +833,16 @@ static void service_sigchld_event(Unit *u, pid_t pid, int code, int status) {
                          * done */
                         break;
 
+                case SERVICE_START:
+                        assert(s->type == SERVICE_FINISH);
+
+                        /* This was our main goal, so let's go on */
+                        if (success)
+                                service_enter_start_post(s);
+                        else
+                                service_enter_stop(s, false);
+                        break;
+
                 case SERVICE_RUNNING:
                         service_enter_stop(s, success);
                         break;