chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
service: trim cgroups if services that are "active" but "exited"
[elogind.git]
/
src
/
service.c
diff --git
a/src/service.c
b/src/service.c
index b837cb81e59c856d54a5d2a89d8bde6d4fa256f7..47108503ddf47ed65a69803b904fcb41f083595a 100644
(file)
--- a/
src/service.c
+++ b/
src/service.c
@@
-631,6
+631,7
@@
static int service_load_sysv_path(Service *s, const char *path) {
goto finish;
}
goto finish;
}
+ free(u->meta.description);
u->meta.description = d;
} else if (startswith_no_case(t, "X-Interactive:")) {
u->meta.description = d;
} else if (startswith_no_case(t, "X-Interactive:")) {
@@
-1178,6
+1179,11
@@
static void service_set_state(Service *s, ServiceState state) {
service_connection_unref(s);
}
service_connection_unref(s);
}
+ /* For the inactive states unit_notify() will trim the cgroup,
+ * but for exit we have to do that ourselves... */
+ if (state == SERVICE_EXITED)
+ cgroup_bonding_trim_list(s->meta.cgroup_bondings, true);
+
if (old_state != state)
log_debug("%s changed %s -> %s", s->meta.id, service_state_to_string(old_state), service_state_to_string(state));
if (old_state != state)
log_debug("%s changed %s -> %s", s->meta.id, service_state_to_string(old_state), service_state_to_string(state));
@@
-2170,7
+2176,6
@@
static void service_sigchld_event(Unit *u, pid_t pid, int code, int status) {
assert(pid >= 0);
success = is_clean_exit(code, status);
assert(pid >= 0);
success = is_clean_exit(code, status);
- s->failure = s->failure || !success;
if (s->main_pid == pid) {
if (s->main_pid == pid) {
@@
-2180,9
+2185,13
@@
static void service_sigchld_event(Unit *u, pid_t pid, int code, int status) {
if (s->type != SERVICE_FORKING) {
assert(s->exec_command[SERVICE_EXEC_START]);
s->exec_command[SERVICE_EXEC_START]->exec_status = s->main_exec_status;
if (s->type != SERVICE_FORKING) {
assert(s->exec_command[SERVICE_EXEC_START]);
s->exec_command[SERVICE_EXEC_START]->exec_status = s->main_exec_status;
+
+ if (s->exec_command[SERVICE_EXEC_START]->ignore)
+ success = true;
}
log_debug("%s: main process exited, code=%s, status=%i", u->meta.id, sigchld_code_to_string(code), status);
}
log_debug("%s: main process exited, code=%s, status=%i", u->meta.id, sigchld_code_to_string(code), status);
+ s->failure = s->failure || !success;
/* The service exited, so the service is officially
* gone. */
/* The service exited, so the service is officially
* gone. */
@@
-2229,12
+2238,17
@@
static void service_sigchld_event(Unit *u, pid_t pid, int code, int status) {
} else if (s->control_pid == pid) {
} else if (s->control_pid == pid) {
- if (s->control_command)
+ if (s->control_command)
{
exec_status_exit(&s->control_command->exec_status, pid, code, status);
exec_status_exit(&s->control_command->exec_status, pid, code, status);
+ if (s->control_command->ignore)
+ success = true;
+ }
+
s->control_pid = 0;
log_debug("%s: control process exited, code=%s status=%i", u->meta.id, sigchld_code_to_string(code), status);
s->control_pid = 0;
log_debug("%s: control process exited, code=%s status=%i", u->meta.id, sigchld_code_to_string(code), status);
+ s->failure = s->failure || !success;
/* If we are shutting things down anyway we
* don't care about failing commands. */
/* If we are shutting things down anyway we
* don't care about failing commands. */