Taken from:
http://gitweb.merproject.org/gitweb?p=mer-core/systemd.git;a=patch;h=
18ee801483fc71f4c423c8e16b039f5902e879b9
See also:
https://bugs.nemomobile.org/show_bug.cgi?id=502
This is a stop-gap measure to shutdown any remaining user-session's.
Systemd still has a race (even in 195) that kills the logic in
user sessions before it can properly exit that same user session. Hence,
the user sessions time out shutting down for 90 seconds. This unit
forces the shutdown procedure again which works.
This is not supposed to be a final solution, which is why I'm
merging it here instead of pushing this fix to systemd itself. Ultimately
this patch needs to be dropped and the original logic made functional.
Thanks to the Mer project for coming up with this one.
=======
From
18ee801483fc71f4c423c8e16b039f5902e879b9 Mon Sep 17 00:00:00 2001
From: Pekka Lundstrom <pekka.lundstrom@jollamobile.com>
Date: Thu, 11 Oct 2012 12:07:07 +0300
Subject: [PATCH] Added file /lib/systemd/system/systemd-stop-user-sessions.service
Fixes NEMO#502: Shutdown is not working properly when systemd user session is used
Signed-off-by: Pekka Lundstrom <pekka.lundstrom@jollamobile.com>
---
systemd-stop-user-sessions.service | 20 ++++++++++++++++++++
systemd.changes | 4 ++++
systemd.spec | 6 ++++++
3 files changed, 30 insertions(+), 0 deletions(-)
create mode 100644 systemd-stop-user-sessions.service
diff --git a/systemd-stop-user-sessions.service b/systemd-stop-user-sessions.service
new file mode 100644
index 0000000..ce24c0f
--- /dev/null
+++ b/systemd-stop-user-sessions.service
@@ -0,0 +1,20 @@
+# This file is part of systemd.
+#
+# systemd is free software; you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License as published by
+# the Free Software Foundation; either version 2.1 of the License, or
+# (at your option) any later version.
+
+[Unit]
+Description=Disable User Sessions
+Documentation=man:systemd-user-sessions.service(8)
+Before=shutdown.target
+DefaultDependencies=no
+
+[Service]
+Type=oneshot
+RemainAfterExit=yes
+ExecStart=/lib/systemd/systemd-user-sessions stop
+
+[Install]
+WantedBy=shutdown.target
diff --git a/systemd.changes b/systemd.changes
index caadfbd..5865f2b 100644
--- a/systemd.changes
+++ b/systemd.changes
@@ -1,3 +1,7 @@
+* Thu Oct 11 2012 Pekka Lundstrom <pekka.lundstrom@jollamobile.com> - 187
+- Added file /lib/systemd/system/systemd-stop-user-sessions.service
+ Fixes NEMO#502: Shutdown is not working properly when systemd user session is used
+
* Mon Aug 27 2012 Marko Saukko <marko.saukko@jollamobile.com> - 187
- Fix tty1 autostart by excluding the file in /etc/systemd/system/getty.target.wants/
diff --git a/systemd.spec b/systemd.spec
index 607570e..9c78060 100644
--- a/systemd.spec
+++ b/systemd.spec
@@ -28,6 +28,7 @@ Requires: filesystem >= 3
# fsck with -l option was introduced in 2.21.2 packaging
Requires: util-linux >= 2.21.2
Source0: http://www.freedesktop.org/software/systemd/%{name}-%{version}.tar.xz
+Source1: systemd-stop-user-sessions.service
Patch0: systemd-185-pkgconfigdir.patch
Patch1: systemd-187-reintroduce-support-for-deprecated-oom.patch
Patch2: systemd-187-video.patch
@@ -255,6 +256,11 @@ rm %{buildroot}/%{_docdir}/systemd/*
mkdir -p %{buildroot}/etc/systemd/system/basic.target.wants
+# Fix shutdown hang problem with user-serssions
+install -D -m 644 %{SOURCE1} %{buildroot}/lib/systemd/system/systemd-stop-user-sessions.service
+mkdir -p %{buildroot}/lib/systemd/system/shutdown.target.wants
+ln -s ../systemd-stop-user-sessions.service %{buildroot}/lib/systemd/system/shutdown.target.wants/systemd-stop-user-sessions.service
+
#console-ttyMFD2
ln -s ../serial-getty@.service %{buildroot}/lib/systemd/system/getty.target.wants/serial-getty@ttyMFD2.service