chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
cgroup: compare fs paths with path_equal() rather than streq()
[elogind.git]
/
src
/
core
/
service.c
diff --git
a/src/core/service.c
b/src/core/service.c
index 6f18cbf759bb98eb1571dd0f5820bd4cfa9103c7..34dde7963e6fdd6d53b375ce37e1953f8004be82 100644
(file)
--- a/
src/core/service.c
+++ b/
src/core/service.c
@@
-191,6
+191,8
@@
static int service_set_main_pid(Service *s, pid_t pid) {
if (pid == getpid())
return -EINVAL;
if (pid == getpid())
return -EINVAL;
+ service_unwatch_main_pid(s);
+
s->main_pid = pid;
s->main_pid_known = true;
s->main_pid = pid;
s->main_pid_known = true;
@@
-1111,6
+1113,12
@@
static int service_verify(Service *s) {
return -EINVAL;
}
return -EINVAL;
}
+ if (s->type == SERVICE_ONESHOT && s->restart != SERVICE_RESTART_NO) {
+ log_error_unit(UNIT(s)->id,
+ "%s has Restart setting other than no, which isn't allowed for Type=oneshot services. Refusing.", UNIT(s)->id);
+ return -EINVAL;
+ }
+
if (s->type == SERVICE_DBUS && !s->bus_name) {
log_error_unit(UNIT(s)->id,
"%s is of type D-Bus but no D-Bus service name has been specified. Refusing.", UNIT(s)->id);
if (s->type == SERVICE_DBUS && !s->bus_name) {
log_error_unit(UNIT(s)->id,
"%s is of type D-Bus but no D-Bus service name has been specified. Refusing.", UNIT(s)->id);
@@
-1617,6
+1625,7
@@
static int service_coldplug(Unit *u) {
s->deserialized_state == SERVICE_FINAL_SIGTERM ||
s->deserialized_state == SERVICE_FINAL_SIGKILL ||
s->deserialized_state == SERVICE_AUTO_RESTART) {
s->deserialized_state == SERVICE_FINAL_SIGTERM ||
s->deserialized_state == SERVICE_FINAL_SIGKILL ||
s->deserialized_state == SERVICE_AUTO_RESTART) {
+
if (s->deserialized_state == SERVICE_AUTO_RESTART || s->timeout_start_usec > 0) {
usec_t k;
if (s->deserialized_state == SERVICE_AUTO_RESTART || s->timeout_start_usec > 0) {
usec_t k;
@@
-1948,6
+1957,12
@@
static void service_enter_dead(Service *s, ServiceResult f, bool allow_restart)
/* we want fresh tmpdirs in case service is started again immediately */
exec_context_tmp_dirs_done(&s->exec_context);
/* we want fresh tmpdirs in case service is started again immediately */
exec_context_tmp_dirs_done(&s->exec_context);
+ /* Try to delete the pid file. At this point it will be
+ * out-of-date, and some software might be confused by it, so
+ * let's remove it. */
+ if (s->pid_file)
+ unlink_noerrno(s->pid_file);
+
return;
fail:
return;
fail:
@@
-1986,7
+2001,7
@@
static void service_enter_stop_post(Service *s, ServiceResult f) {
service_set_state(s, SERVICE_STOP_POST);
} else
service_set_state(s, SERVICE_STOP_POST);
} else
- service_enter_
signal(s, SERVICE_FINAL_SIGTERM, SERVICE_SUCCESS
);
+ service_enter_
dead(s, SERVICE_SUCCESS, true
);
return;
return;
@@
-2144,7
+2159,6
@@
static void service_kill_control_processes(Service *s) {
return;
p = strappenda(UNIT(s)->cgroup_path, "/control");
return;
p = strappenda(UNIT(s)->cgroup_path, "/control");
-
cg_kill_recursive(SYSTEMD_CGROUP_CONTROLLER, p, SIGKILL, true, true, true, NULL);
}
cg_kill_recursive(SYSTEMD_CGROUP_CONTROLLER, p, SIGKILL, true, true, true, NULL);
}
@@
-2158,10
+2172,8
@@
static void service_enter_start(Service *s) {
assert(s->exec_command[SERVICE_EXEC_START]);
assert(!s->exec_command[SERVICE_EXEC_START]->command_next || s->type == SERVICE_ONESHOT);
assert(s->exec_command[SERVICE_EXEC_START]);
assert(!s->exec_command[SERVICE_EXEC_START]->command_next || s->type == SERVICE_ONESHOT);
- if (s->type == SERVICE_FORKING)
- service_unwatch_control_pid(s);
- else
- service_unwatch_main_pid(s);
+ service_unwatch_control_pid(s);
+ service_unwatch_main_pid(s);
/* We want to ensure that nobody leaks processes from
* START_PRE here, so let's go on a killing spree, People
/* We want to ensure that nobody leaks processes from
* START_PRE here, so let's go on a killing spree, People
@@
-3322,8
+3334,7
@@
static void service_notify_cgroup_empty_event(Unit *u) {
assert(u);
assert(u);
- log_debug_unit(u->id,
- "%s: cgroup is empty", u->id);
+ log_debug_unit(u->id, "%s: cgroup is empty", u->id);
switch (s->state) {
switch (s->state) {
@@
-3752,6
+3763,7
@@
static void service_reset_failed(Unit *u) {
static int service_kill(Unit *u, KillWho who, int signo, DBusError *error) {
Service *s = SERVICE(u);
static int service_kill(Unit *u, KillWho who, int signo, DBusError *error) {
Service *s = SERVICE(u);
+
return unit_kill_common(u, who, signo, s->main_pid, s->control_pid, error);
}
return unit_kill_common(u, who, signo, s->main_pid, s->control_pid, error);
}