]> rtime.felk.cvut.cz Git - sojka/lightdm.git/blob - debian/lightdm-greeter-session
debian/lightdm-greeter-session: Don't launch another session D-Bus if one
[sojka/lightdm.git] / debian / lightdm-greeter-session
1 #!/bin/sh
2 # -*- Mode: sh; indent-tabs-mode: nil; tab-width: 4 -*-
3 #
4 # Copyright (C) 2011 Canonical Ltd
5 # Author: Michael Terry <michael.terry@canonical.com>
6 #
7 # This program is free software: you can redistribute it and/or modify it under
8 # the terms of the GNU General Public License as published by the Free Software
9 # Foundation, version 3 of the License.
10 #
11 # See http://www.gnu.org/copyleft/gpl.html the full text of the license.
12
13 # This wrapper merely ensures that dbus-daemon lives only as long as this
14 # script does.  Otherwise, it's very easy for dbus-daemon to be autolaunched
15 # and detached from the greeter.
16
17 trap cleanup TERM EXIT
18
19 cleanup()
20 {
21     trap - TERM EXIT
22     if [ -n "$DBUS_SESSION_BUS_PID" ]; then
23         kill "$DBUS_SESSION_BUS_PID"
24     fi
25     if [ -n "$CMD_PID" ]; then
26         kill "$CMD_PID"
27     fi
28     exit 0
29 }
30
31 [ -n "$DBUS_SESSION_BUS_ADDRESS" ] || eval `dbus-launch --sh-syntax`
32
33 exec $@ &
34 CMD_PID=$!
35 wait $CMD_PID
36 CMD_PID=