chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
units: add console-shell.service which can be used insted of the gettys to get a...
[elogind.git]
/
src
/
service.c
diff --git
a/src/service.c
b/src/service.c
index e928d1a5e0050fd533fdd2bbb64b27756bf06229..e7a9e7c586c15c0f106f0cd4d62c583d983043cd 100644
(file)
--- a/
src/service.c
+++ b/
src/service.c
@@
-275,7
+275,13
@@
static int sysv_translate_facility(const char *name, const char *filename, char
static const char * const table[] = {
/* LSB defined facilities */
"local_fs", SPECIAL_LOCAL_FS_TARGET,
static const char * const table[] = {
/* LSB defined facilities */
"local_fs", SPECIAL_LOCAL_FS_TARGET,
+#ifndef TARGET_MANDRIVA
+ /* Due to unfortunate name selection in Mandriva,
+ * $network is provided by network-up which is ordered
+ * after network which actually starts interfaces.
+ * To break the loop, just ignore it */
"network", SPECIAL_NETWORK_TARGET,
"network", SPECIAL_NETWORK_TARGET,
+#endif
"named", SPECIAL_NSS_LOOKUP_TARGET,
"portmap", SPECIAL_RPCBIND_TARGET,
"remote_fs", SPECIAL_REMOTE_FS_TARGET,
"named", SPECIAL_NSS_LOOKUP_TARGET,
"portmap", SPECIAL_RPCBIND_TARGET,
"remote_fs", SPECIAL_REMOTE_FS_TARGET,
@@
-335,7
+341,7
@@
static int sysv_translate_facility(const char *name, const char *filename, char
/* Facilities starting with $ are most likely targets */
r = unit_name_build(n, NULL, ".target");
} else if (filename && streq(name, filename))
/* Facilities starting with $ are most likely targets */
r = unit_name_build(n, NULL, ".target");
} else if (filename && streq(name, filename))
- /* Names equal
l
ing the file name of the services are redundant */
+ /* Names equaling the file name of the services are redundant */
return 0;
else
/* Everything else we assume to be normal service names */
return 0;
else
/* Everything else we assume to be normal service names */
@@
-345,9
+351,7
@@
static int sysv_translate_facility(const char *name, const char *filename, char
return -ENOMEM;
finish:
return -ENOMEM;
finish:
-
- if (_r)
- *_r = r;
+ *_r = r;
return 1;
}
return 1;
}
@@
-837,7
+841,7
@@
static int service_load_sysv_path(Service *s, const char *path) {
if (description) {
char *d;
if (description) {
char *d;
- if (!(d = strappend(
"LSB
: ", description))) {
+ if (!(d = strappend(
s->sysv_has_lsb ? "LSB: " : "SYSV
: ", description))) {
r = -ENOMEM;
goto finish;
}
r = -ENOMEM;
goto finish;
}
@@
-1655,7
+1659,7
@@
static int service_spawn(
}
if (set_notify_socket)
}
if (set_notify_socket)
- if (asprintf(our_env + n_env++, "NOTIFY_SOCKET=
@
%s", s->meta.manager->notify_socket) < 0) {
+ if (asprintf(our_env + n_env++, "NOTIFY_SOCKET=%s", s->meta.manager->notify_socket) < 0) {
r = -ENOMEM;
goto fail;
}
r = -ENOMEM;
goto fail;
}
@@
-1830,9
+1834,9
@@
static void service_enter_signal(Service *s, ServiceState state, bool success) {
int sig = (state == SERVICE_STOP_SIGTERM || state == SERVICE_FINAL_SIGTERM) ? s->exec_context.kill_signal : SIGKILL;
if (s->main_pid > 0) {
int sig = (state == SERVICE_STOP_SIGTERM || state == SERVICE_FINAL_SIGTERM) ? s->exec_context.kill_signal : SIGKILL;
if (s->main_pid > 0) {
- if (kill(s->exec_context.kill_mode == KILL_PROCESS_GROUP ?
- -s->main_pid :
- s->main_pid, sig) < 0 && errno != ESRCH)
+ if (kill
_and_sigcont
(s->exec_context.kill_mode == KILL_PROCESS_GROUP ?
+
-s->main_pid :
+
s->main_pid, sig) < 0 && errno != ESRCH)
log_warning("Failed to kill main process %li: %m", (long) s->main_pid);
else
log_warning("Failed to kill main process %li: %m", (long) s->main_pid);
else
@@
-1840,9
+1844,9
@@
static void service_enter_signal(Service *s, ServiceState state, bool success) {
}
if (s->control_pid > 0) {
}
if (s->control_pid > 0) {
- if (kill(s->exec_context.kill_mode == KILL_PROCESS_GROUP ?
- -s->control_pid :
- s->control_pid, sig) < 0 && errno != ESRCH)
+ if (kill
_and_sigcont
(s->exec_context.kill_mode == KILL_PROCESS_GROUP ?
+
-s->control_pid :
+
s->control_pid, sig) < 0 && errno != ESRCH)
log_warning("Failed to kill control process %li: %m", (long) s->control_pid);
else
log_warning("Failed to kill control process %li: %m", (long) s->control_pid);
else
@@
-1865,7
+1869,7
@@
static void service_enter_signal(Service *s, ServiceState state, bool success) {
if ((r = set_put(pid_set, LONG_TO_PTR(s->control_pid))) < 0)
goto fail;
if ((r = set_put(pid_set, LONG_TO_PTR(s->control_pid))) < 0)
goto fail;
- if ((r = cgroup_bonding_kill_list(s->meta.cgroup_bondings, sig, pid_set)) < 0) {
+ if ((r = cgroup_bonding_kill_list(s->meta.cgroup_bondings, sig,
true,
pid_set)) < 0) {
if (r != -EAGAIN && r != -ESRCH && r != -ENOENT)
log_warning("Failed to kill control group: %s", strerror(-r));
} else if (r > 0)
if (r != -EAGAIN && r != -ESRCH && r != -ENOENT)
log_warning("Failed to kill control group: %s", strerror(-r));
} else if (r > 0)
@@
-2496,16
+2500,26
@@
static const char *service_sub_state_to_string(Unit *u) {
return service_state_to_string(SERVICE(u)->state);
}
return service_state_to_string(SERVICE(u)->state);
}
-#ifdef HAVE_SYSV_COMPAT
static bool service_check_gc(Unit *u) {
Service *s = SERVICE(u);
assert(s);
static bool service_check_gc(Unit *u) {
Service *s = SERVICE(u);
assert(s);
- return !!s->sysv_path;
-}
+ /* Never clean up services that still have a process around,
+ * even if the service is formally dead. */
+ if (cgroup_good(s) > 0 ||
+ main_pid_good(s) > 0 ||
+ control_pid_good(s) > 0)
+ return true;
+
+#ifdef HAVE_SYSV_COMPAT
+ if (s->sysv_path)
+ return true;
#endif
#endif
+ return false;
+}
+
static bool service_check_snapshot(Unit *u) {
Service *s = SERVICE(u);
static bool service_check_snapshot(Unit *u) {
Service *s = SERVICE(u);
@@
-2767,7
+2781,7
@@
static void service_timer_event(Unit *u, uint64_t elapsed, Watch* w) {
break;
case SERVICE_STOP_SIGKILL:
break;
case SERVICE_STOP_SIGKILL:
- /* Uh, w
i
e sent a SIGKILL and it is still not gone?
+ /* Uh, we sent a SIGKILL and it is still not gone?
* Must be something we cannot kill, so let's just be
* weirded out and continue */
* Must be something we cannot kill, so let's just be
* weirded out and continue */
@@
-3042,7
+3056,7
@@
static int service_enumerate(Manager *m) {
/* We honour K links only for halt/reboot. For the normal
* runlevels we assume the stop jobs will be implicitly added
/* We honour K links only for halt/reboot. For the normal
* runlevels we assume the stop jobs will be implicitly added
- * by the core logic. Also, we don't really dist
uing
ish here
+ * by the core logic. Also, we don't really dist
ingu
ish here
* between the runlevels 0 and 6 and just add them to the
* special shutdown target. On SUSE the boot.d/ runlevel is
* also used for shutdown, so we add links for that too to the
* between the runlevels 0 and 6 and just add them to the
* special shutdown target. On SUSE the boot.d/ runlevel is
* also used for shutdown, so we add links for that too to the
@@
-3220,7
+3234,7
@@
static int service_kill(Unit *u, KillWho who, KillMode mode, int signo, DBusErro
goto finish;
}
goto finish;
}
- if ((q = cgroup_bonding_kill_list(s->meta.cgroup_bondings, signo, pid_set)) < 0)
+ if ((q = cgroup_bonding_kill_list(s->meta.cgroup_bondings, signo,
false,
pid_set)) < 0)
if (r != -EAGAIN && r != -ESRCH && r != -ENOENT)
r = q;
}
if (r != -EAGAIN && r != -ESRCH && r != -ENOENT)
r = q;
}
@@
-3317,9
+3331,7
@@
const UnitVTable service_vtable = {
.active_state = service_active_state,
.sub_state_to_string = service_sub_state_to_string,
.active_state = service_active_state,
.sub_state_to_string = service_sub_state_to_string,
-#ifdef HAVE_SYSV_COMPAT
.check_gc = service_check_gc,
.check_gc = service_check_gc,
-#endif
.check_snapshot = service_check_snapshot,
.sigchld_event = service_sigchld_event,
.check_snapshot = service_check_snapshot,
.sigchld_event = service_sigchld_event,