chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
cmdline: we actually want to parse the kernel cmdline in VMs, just not in containers
[elogind.git]
/
src
/
service.c
diff --git
a/src/service.c
b/src/service.c
index 1735a96c80b930844d9d24d2d94e4d63692ed24e..7f8d005f00882f21bfcba666cc347b3b1ed8dc9d 100644
(file)
--- a/
src/service.c
+++ b/
src/service.c
@@
-115,6
+115,7
@@
static void service_init(Unit *u) {
s->timer_watch.type = WATCH_INVALID;
#ifdef HAVE_SYSV_COMPAT
s->sysv_start_priority = -1;
s->timer_watch.type = WATCH_INVALID;
#ifdef HAVE_SYSV_COMPAT
s->sysv_start_priority = -1;
+ s->sysv_start_priority_from_rcnd = -1;
#endif
s->socket_fd = -1;
s->guess_main_pid = true;
#endif
s->socket_fd = -1;
s->guess_main_pid = true;
@@
-285,7
+286,7
@@
static int sysv_translate_facility(const char *name, const char *filename, char
"portmap", SPECIAL_RPCBIND_TARGET,
"remote_fs", SPECIAL_REMOTE_FS_TARGET,
"syslog", SPECIAL_SYSLOG_TARGET,
"portmap", SPECIAL_RPCBIND_TARGET,
"remote_fs", SPECIAL_REMOTE_FS_TARGET,
"syslog", SPECIAL_SYSLOG_TARGET,
- "time", SPECIAL_
RTC_SET
_TARGET,
+ "time", SPECIAL_
TIME_SYNC
_TARGET,
/* common extensions */
"mail-transfer-agent", SPECIAL_MAIL_TRANSFER_AGENT_TARGET,
/* common extensions */
"mail-transfer-agent", SPECIAL_MAIL_TRANSFER_AGENT_TARGET,
@@
-405,7
+406,7
@@
static int sysv_fix_order(Service *s) {
/* FIXME: Maybe we should compare the name here lexicographically? */
/* FIXME: Maybe we should compare the name here lexicographically? */
- if (
!
(r = unit_add_dependency(UNIT(s), d, UNIT(t), true)) < 0)
+ if ((r = unit_add_dependency(UNIT(s), d, UNIT(t), true)) < 0)
return r;
}
return r;
}
@@
-537,7
+538,7
@@
static int service_load_sysv_path(Service *s, const char *path) {
* data from the LSB header. */
if (start_priority < 0 || start_priority > 99)
log_warning("[%s:%u] Start priority out of range. Ignoring.", path, line);
* data from the LSB header. */
if (start_priority < 0 || start_priority > 99)
log_warning("[%s:%u] Start priority out of range. Ignoring.", path, line);
- else
if (s->sysv_start_priority < 0)
+ else
s->sysv_start_priority = start_priority;
char_array_0(runlevels);
s->sysv_start_priority = start_priority;
char_array_0(runlevels);
@@
-828,7
+829,7
@@
static int service_load_sysv_path(Service *s, const char *path) {
s->exec_context.std_output =
(s->meta.manager->sysv_console || s->exec_context.std_input == EXEC_INPUT_TTY)
? EXEC_OUTPUT_TTY : s->meta.manager->default_std_output;
s->exec_context.std_output =
(s->meta.manager->sysv_console || s->exec_context.std_input == EXEC_INPUT_TTY)
? EXEC_OUTPUT_TTY : s->meta.manager->default_std_output;
- s->exec_context.kill_mode = KILL_PROCESS
_GROUP
;
+ s->exec_context.kill_mode = KILL_PROCESS;
/* We use the long description only if
* no short description is set. */
/* We use the long description only if
* no short description is set. */
@@
-853,6
+854,12
@@
static int service_load_sysv_path(Service *s, const char *path) {
u->meta.description = d;
}
u->meta.description = d;
}
+ /* The priority that has been set in /etc/rcN.d/ hierarchies
+ * takes precedence over what is stored as default in the LSB
+ * header */
+ if (s->sysv_start_priority_from_rcnd >= 0)
+ s->sysv_start_priority = s->sysv_start_priority_from_rcnd;
+
u->meta.load_state = UNIT_LOADED;
r = 0;
u->meta.load_state = UNIT_LOADED;
r = 0;
@@
-1017,7
+1024,7
@@
static int fsck_fix_order(Service *s) {
else
continue;
else
continue;
- if (
!
(r = unit_add_dependency(UNIT(s), d, UNIT(t), true)) < 0)
+ if ((r = unit_add_dependency(UNIT(s), d, UNIT(t), true)) < 0)
return r;
}
return r;
}
@@
-1585,8
+1592,8
@@
static int service_collect_fds(Service *s, int **fds, unsigned *n_fds) {
goto fail;
}
goto fail;
}
- memcpy(t, rfds, rn_fds);
- memcpy(t+rn_fds, cfds, cn_fds);
+ memcpy(t, rfds, rn_fds
* sizeof(int)
);
+ memcpy(t+rn_fds, cfds, cn_fds
* sizeof(int)
);
free(rfds);
free(cfds);
free(rfds);
free(cfds);
@@
-1838,19
+1845,14
@@
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_and_sigcont(s->exec_context.kill_mode == KILL_PROCESS_GROUP ?
- -s->main_pid :
- s->main_pid, sig) < 0 && errno != ESRCH)
-
+ if (kill_and_sigcont(s->main_pid, sig) < 0 && errno != ESRCH)
log_warning("Failed to kill main process %li: %m", (long) s->main_pid);
else
wait_for_exit = true;
}
if (s->control_pid > 0) {
log_warning("Failed to kill main process %li: %m", (long) s->main_pid);
else
wait_for_exit = true;
}
if (s->control_pid > 0) {
- if (kill_and_sigcont(s->exec_context.kill_mode == KILL_PROCESS_GROUP ?
- -s->control_pid :
- s->control_pid, sig) < 0 && errno != ESRCH)
+ if (kill_and_sigcont(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
@@
-1880,6
+1882,7
@@
static void service_enter_signal(Service *s, ServiceState state, bool success) {
wait_for_exit = true;
set_free(pid_set);
wait_for_exit = true;
set_free(pid_set);
+ pid_set = NULL;
}
}
}
}
@@
-3014,8
+3017,8
@@
static int service_enumerate(Manager *m) {
if (de->d_name[0] == 'S') {
if (rcnd_table[i].type == RUNLEVEL_UP || rcnd_table[i].type == RUNLEVEL_SYSINIT) {
if (de->d_name[0] == 'S') {
if (rcnd_table[i].type == RUNLEVEL_UP || rcnd_table[i].type == RUNLEVEL_SYSINIT) {
- SERVICE(service)->sysv_start_priority =
- MAX(a*10 + b, SERVICE(service)->sysv_start_priority);
+ SERVICE(service)->sysv_start_priority
_from_rcnd
=
+ MAX(a*10 + b, SERVICE(service)->sysv_start_priority
_from_rcnd
);
SERVICE(service)->sysv_enabled = true;
}
SERVICE(service)->sysv_enabled = true;
}
@@
-3212,11
+3215,11
@@
static int service_kill(Unit *u, KillWho who, KillMode mode, int signo, DBusErro
}
if (s->control_pid > 0)
}
if (s->control_pid > 0)
- if (kill(
mode == KILL_PROCESS_GROUP ? -s->control_pid :
s->control_pid, signo) < 0)
+ if (kill(s->control_pid, signo) < 0)
r = -errno;
if (s->main_pid > 0)
r = -errno;
if (s->main_pid > 0)
- if (kill(
mode == KILL_PROCESS_GROUP ? -s->main_pid :
s->main_pid, signo) < 0)
+ if (kill(s->main_pid, signo) < 0)
r = -errno;
if (mode == KILL_CONTROL_GROUP) {
r = -errno;
if (mode == KILL_CONTROL_GROUP) {