SHA256
1
0
forked from pool/systemd
systemd/remain_after_exit-initscript-heuristic-and-add-new-LSB-hea.patch
Marcus Meissner 28dd57258d Accepting request 176957 from home:fcrozat:branches:Base:System
- Update to release 204:
  + systemd-nspawn creates etc/resolv.conf in container if needed.
  + systemd-nspawn will store metadata about container in container
    cgroup including its root directory.
  + cgroup hierarchy has been reworked, all objects are now suffxed
    (with .session for user sessions, .user for users, .nspawn for
     containers). All cgroup names are now escaped to preven
     collision of object names.
  + systemctl list-dependencies gained --plain, --reverse, --after
    and --before switches.
  + systemd-inhibit shows processes name taking inhibitor lock.
  + nss-myhostname will now resolve "localhost" implicitly.
  + .include is not allowed recursively anymore and only in unit
    files. Drop-in files should be favored in most cases.
  + systemd-analyze gained "critical-chain" command, to get slowest
    chain of units run during boot-up.
  + systemd-nspawn@.service has been added to easily run nspawn
    container for system services. Just start
    "systemd-nspawn@foobar.service" and container from
    /var/lib/container/foobar" will be booted.
  + systemd-cgls has new --machine parameter to list processes from
    one container.
  + ConditionSecurity= can now check for apparmor and SMACK.
  + /etc/systemd/sleep.conf has been introduced to configure which
    kernel operation will be execute when "suspend", "hibernate" or
    "hybrid-sleep" is requrested. It allow new kernel "freeze"
    state to be used too. (This setting won't have any effect if
    pm-utils is installed).
  + ENV{SYSTEMD_WANTS} in udev rules will now implicitly escape
    passed argument if applicable.

OBS-URL: https://build.opensuse.org/request/show/176957
OBS-URL: https://build.opensuse.org/package/show/Base:System/systemd?expand=0&rev=388
2013-05-29 15:26:40 +00:00

92 lines
3.9 KiB
Diff

From: Frederic Crozat <fcrozat@suse.com>
Date: Wed, 7 Dec 2011 15:15:07 +0000
Subject: remain_after_exit initscript heuristic and add new LSB headers
Add remain_after_exit heuristic for initscripts and add LSB headers
PIDFile: and X-Systemd-RemainAfterExit to control it.
(bnc#721426) (bnc#727771)
---
src/core/service.c | 34 ++++++++++++++++++++++++++++++++--
src/core/service.h | 1 +
2 files changed, 33 insertions(+), 2 deletions(-)
diff --git a/src/core/service.c b/src/core/service.c
index a8b0d9d..c357b33 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -135,6 +135,7 @@ static void service_init(Unit *u) {
#ifdef HAVE_SYSV_COMPAT
s->sysv_start_priority = -1;
s->sysv_start_priority_from_rcnd = -1;
+ s->sysv_remain_after_exit_heuristic = true;
#endif
s->socket_fd = -1;
s->guess_main_pid = true;
@@ -875,6 +876,34 @@ static int service_load_sysv_path(Service *s, const char *path) {
free(short_description);
short_description = d;
+ } else if (startswith_no_case(t, "PIDFile:")) {
+ char *fn;
+
+ state = LSB;
+
+ fn = strstrip(t+8);
+ if (!path_is_absolute(fn)) {
+ log_warning("[%s:%u] PID file not absolute. Ignoring.", path, line);
+ continue;
+ }
+
+ if (!(fn = strdup(fn))) {
+ r = -ENOMEM;
+ goto finish;
+ }
+
+ free(s->pid_file);
+ s->pid_file = fn;
+ s->sysv_remain_after_exit_heuristic = false;
+ s->remain_after_exit = false;
+ } else if (startswith_no_case(t, "X-Systemd-RemainAfterExit:")) {
+ char *j;
+
+ state = LSB;
+ if ((j = strstrip(t+26)) && *j) {
+ s->remain_after_exit = parse_boolean(j);
+ s->sysv_remain_after_exit_heuristic = false;
+ }
} else if (state == LSB_DESCRIPTION) {
if (startswith(l, "#\t") || startswith(l, "# ")) {
@@ -925,7 +954,8 @@ static int service_load_sysv_path(Service *s, const char *path) {
/* Special setting for all SysV services */
s->type = SERVICE_FORKING;
- s->remain_after_exit = !s->pid_file;
+ if (s->sysv_remain_after_exit_heuristic)
+ s->remain_after_exit = !s->pid_file;
s->guess_main_pid = false;
s->restart = SERVICE_RESTART_NO;
s->exec_context.ignore_sigpipe = false;
@@ -2077,7 +2107,7 @@ static void service_enter_running(Service *s, ServiceResult f) {
if ((main_pid_ok > 0 || (main_pid_ok < 0 && cgroup_ok != 0)) &&
(s->bus_name_good || s->type != SERVICE_DBUS)) {
#ifdef HAVE_SYSV_COMPAT
- if (s->sysv_enabled && !s->pid_file)
+ if (s->sysv_enabled && !s->pid_file && s->sysv_remain_after_exit_heuristic)
s->remain_after_exit = false;
#endif
service_set_state(s, SERVICE_RUNNING);
diff --git a/src/core/service.h b/src/core/service.h
index 703d3fa..dc52e8c 100644
--- a/src/core/service.h
+++ b/src/core/service.h
@@ -176,6 +176,7 @@ struct Service {
bool is_sysv:1;
bool sysv_has_lsb:1;
bool sysv_enabled:1;
+ bool sysv_remain_after_exit_heuristic:1;
int sysv_start_priority_from_rcnd;
int sysv_start_priority;