chiark / gitweb /
cgroup: mount cgroup file systems to /sys/fs/cgroup instead of /cgroup
[elogind.git] / src / service.c
index ee952810fc138b35c4ff2d7cc968a1cfb76cae73..d2ef1ad9070e11993ec103d1b16e04d42881b4f5 100644 (file)
@@ -1,4 +1,4 @@
-/*-*- Mode: C; c-basic-offset: 8 -*-*/
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
 
 /***
   This file is part of systemd.
@@ -488,7 +488,7 @@ static int service_load_sysv_path(Service *s, const char *path) {
                                         t[k-1] = 0;
                                 }
 
-                                if (!(d = strdup(strstrip(t+12)))) {
+                                if (!(d = strappend("LSB: ", strstrip(t+12)))) {
                                         r = -ENOMEM;
                                         goto finish;
                                 }
@@ -635,7 +635,7 @@ static int service_load_sysv_path(Service *s, const char *path) {
 
                                 state = LSB_DESCRIPTION;
 
-                                if (!(d = strdup(strstrip(t+12)))) {
+                                if (!(d = strappend("LSB: ", strstrip(t+12)))) {
                                         r = -ENOMEM;
                                         goto finish;
                                 }
@@ -648,7 +648,7 @@ static int service_load_sysv_path(Service *s, const char *path) {
 
                                 state = LSB;
 
-                                if (!(d = strdup(strstrip(t+18)))) {
+                                if (!(d = strappend("LSB: ", strstrip(t+18)))) {
                                         r = -ENOMEM;
                                         goto finish;
                                 }
@@ -706,9 +706,11 @@ static int service_load_sysv_path(Service *s, const char *path) {
 
         /* Special setting for all SysV services */
         s->type = SERVICE_FORKING;
-        s->valid_no_process = true;
+        s->remain_after_exit = true;
         s->restart = SERVICE_ONCE;
-        s->exec_context.std_output = s->meta.manager->sysv_console ? EXEC_OUTPUT_TTY : EXEC_OUTPUT_NULL;
+        s->exec_context.std_output =
+                (s->meta.manager->sysv_console || s->exec_context.std_input == EXEC_INPUT_TTY)
+                ? EXEC_OUTPUT_TTY : EXEC_OUTPUT_NULL;
         s->exec_context.kill_mode = KILL_PROCESS_GROUP;
 
         u->meta.load_state = UNIT_LOADED;
@@ -951,14 +953,14 @@ static void service_dump(Unit *u, FILE *f, const char *prefix) {
                 "%sService State: %s\n"
                 "%sPermissionsStartOnly: %s\n"
                 "%sRootDirectoryStartOnly: %s\n"
-                "%sValidNoProcess: %s\n"
+                "%sRemainAfterExit: %s\n"
                 "%sType: %s\n"
                 "%sRestart: %s\n"
                 "%sNotifyAccess: %s\n",
                 prefix, service_state_to_string(s->state),
                 prefix, yes_no(s->permissions_start_only),
                 prefix, yes_no(s->root_directory_start_only),
-                prefix, yes_no(s->valid_no_process),
+                prefix, yes_no(s->remain_after_exit),
                 prefix, service_type_to_string(s->type),
                 prefix, service_restart_to_string(s->restart),
                 prefix, notify_access_to_string(s->notify_access));
@@ -1669,7 +1671,7 @@ static void service_enter_running(Service *s, bool success) {
         if ((main_pid_ok > 0 || (main_pid_ok < 0 && cgroup_ok != 0)) &&
             (s->bus_name_good || s->type != SERVICE_DBUS))
                 service_set_state(s, SERVICE_RUNNING);
-        else if (s->valid_no_process)
+        else if (s->remain_after_exit)
                 service_set_state(s, SERVICE_EXITED);
         else
                 service_enter_stop(s, true);
@@ -2261,7 +2263,10 @@ static void service_sigchld_event(Unit *u, pid_t pid, int code, int status) {
         assert(s);
         assert(pid >= 0);
 
-        success = is_clean_exit(code, status);
+        if (s->sysv_path)
+                success = is_clean_exit_lsb(code, status);
+        else
+                success = is_clean_exit(code, status);
 
         if (s->main_pid == pid) {
 
@@ -2449,6 +2454,9 @@ static void service_sigchld_event(Unit *u, pid_t pid, int code, int status) {
                         }
                 }
         }
+
+        /* Notify clients about changed exit status */
+        unit_add_to_dbus_queue(u);
 }
 
 static void service_timer_event(Unit *u, uint64_t elapsed, Watch* w) {
@@ -2605,6 +2613,9 @@ static void service_notify_message(Unit *u, pid_t pid, char **tags) {
                 }
 
         }
+
+        /* Notify clients about changed status or main pid */
+        unit_add_to_dbus_queue(u);
 }
 
 static int service_enumerate(Manager *m) {
@@ -2939,7 +2950,9 @@ const UnitVTable service_vtable = {
         .bus_name_owner_change = service_bus_name_owner_change,
         .bus_query_pid_done = service_bus_query_pid_done,
 
+        .bus_interface = "org.freedesktop.systemd1.Service",
         .bus_message_handler = bus_service_message_handler,
+        .bus_invalidating_properties =  bus_service_invalidating_properties,
 
         .enumerate = service_enumerate
 };