summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2012-02-07 19:58:44 +0000
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2013-06-05 17:58:52 +0100
commit9760bdf393211a9bc79432de54cb4252f8724723 (patch)
treecf192f306a543fd771a77bd91ee5491d56f4ded8 /tools
parent9c0ef7028893e4db18fe901ed749784c99a8839f (diff)
downloaddbus-9760bdf393211a9bc79432de54cb4252f8724723.tar.gz
massively simplify run-with-tmp-session-bus.sh by using dbus-run-session
It turns out that if you don't second-guess the system by catching SIGINT, the right things happen: it's received by every program in the foreground process group, including dbus-run-session and dbus-daemon. Neither of those catch SIGINT (unlike dbus-launch) so they'll exit gracefully without the wrapper script needing to do anything special. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=39196 Reviewed-by: Colin Walters <walters@verbum.org>
Diffstat (limited to 'tools')
-rwxr-xr-xtools/run-with-tmp-session-bus.sh45
1 files changed, 12 insertions, 33 deletions
diff --git a/tools/run-with-tmp-session-bus.sh b/tools/run-with-tmp-session-bus.sh
index c39999fb..3245652e 100755
--- a/tools/run-with-tmp-session-bus.sh
+++ b/tools/run-with-tmp-session-bus.sh
@@ -1,16 +1,12 @@
#! /bin/sh
-SCRIPTNAME=$0
-WRAPPED_SCRIPT=$1
+SCRIPTNAME="$0"
+WRAPPED_SCRIPT="$1"
shift
-die()
+die ()
{
- if ! test -z "$DBUS_SESSION_BUS_PID" ; then
- echo "killing message bus "$DBUS_SESSION_BUS_PID >&2
- kill -9 $DBUS_SESSION_BUS_PID
- fi
- echo $SCRIPTNAME: $* >&2
+ echo "$SCRIPTNAME: $*" >&2
exit 1
}
@@ -18,9 +14,6 @@ if test -z "$DBUS_TOP_BUILDDIR" ; then
die "Must set DBUS_TOP_BUILDDIR"
fi
-## convenient to be able to ctrl+C without leaking the message bus process
-trap 'die "Received SIGINT"' INT
-
CONFIG_FILE=./run-with-tmp-session-bus.conf
SERVICE_DIR="$DBUS_TOP_BUILDDIR/test/data/valid-service-files"
ESCAPED_SERVICE_DIR=`echo $SERVICE_DIR | sed -e 's/\//\\\\\\//g'`
@@ -50,27 +43,13 @@ export LD_LIBRARY_PATH
unset DBUS_SESSION_BUS_ADDRESS
unset DBUS_SESSION_BUS_PID
-echo "Running $DBUS_TOP_BUILDDIR/tools/dbus-launch --sh-syntax --config-file=$CONFIG_FILE" >&2
-
-DBUS_USE_TEST_BINARY=1
+# this does not actually affect dbus-run-session any more, but could be
+# significant for dbus-launch as used by the autolaunch test
+DBUS_USE_TEST_BINARY=1
export DBUS_USE_TEST_BINARY
-eval `$DBUS_TOP_BUILDDIR/tools/dbus-launch --sh-syntax --config-file=$CONFIG_FILE`
-
-if test -z "$DBUS_SESSION_BUS_PID" ; then
- die "Failed to launch message bus for test script to run"
-fi
-
-echo "Started bus pid $DBUS_SESSION_BUS_PID at $DBUS_SESSION_BUS_ADDRESS" >&2
-
-# Execute wrapped script
-echo "Running $WRAPPED_SCRIPT $@" >&2
-$WRAPPED_SCRIPT "$@" || die "script \"$WRAPPED_SCRIPT\" failed"
-
-kill -TERM $DBUS_SESSION_BUS_PID || die "Message bus vanished! should not have happened" && echo "Killed daemon $DBUS_SESSION_BUS_PID" >&2
-
-sleep 2
-
-## be sure it really died
-kill -9 $DBUS_SESSION_BUS_PID > /dev/null 2>&1 || true
-exit 0
+exec $DBUS_TOP_BUILDDIR/tools/dbus-run-session \
+ --config-file="$CONFIG_FILE" \
+ --dbus-daemon="$DBUS_TOP_BUILDDIR/bus/dbus-daemon" \
+ -- \
+ "$WRAPPED_SCRIPT" "$@"