summaryrefslogtreecommitdiff
path: root/debian/local
diff options
context:
space:
mode:
authorBrice Goglin <Brice.Goglin@ens-lyon.org>2007-03-08 20:34:11 +0100
committerDrew Parsons <dparsons@debian.org>2007-03-10 23:37:42 +1100
commit5cbab1b34dc2bbc1d54dd3c379fc5cf8262487b3 (patch)
tree852ac22b20af41657e135bc528f50ab87492b25f /debian/local
parentf0a5786ea1fc62d4ab7611ea495c156fe012132c (diff)
* Apply patch from adrian@smop.co.uk to our xvfb-run wrapper
to check whether Xvfb started ok and fix its cleanup (closes: #351042).
Diffstat (limited to 'debian/local')
-rw-r--r--debian/local/xvfb-run29
1 files changed, 20 insertions, 9 deletions
diff --git a/debian/local/xvfb-run b/debian/local/xvfb-run
index a5ff11b00..5bbd88613 100644
--- a/debian/local/xvfb-run
+++ b/debian/local/xvfb-run
@@ -81,6 +81,19 @@ find_free_servernum() {
echo $i
}
+# Clean up files
+clean_up() {
+ if [ -e "$AUTHFILE" ]; then
+ XAUTHORITY=$AUTHFILE xauth remove ":$SERVERNUM" >"$ERRORFILE" 2>&1
+ fi
+ if [ -n "$XVFB_RUN_TMPDIR" ]; then
+ if ! rm -r "$XVFB_RUN_TMPDIR"; then
+ error "problem while cleaning up temporary directory"
+ exit 5
+ fi
+ fi
+}
+
# Parse the command line.
ARGS=$(getopt --options +ae:f:hn:lp:s:w: \
--long auto-servernum,error-file:,auth-file:,help,server-num:,listen-tcp,xauth-protocol:,server-args:,wait: \
@@ -128,6 +141,9 @@ if ! which xauth >/dev/null; then
exit 3
fi
+# tidy up after ourselves
+trap clean_up EXIT
+
# If the user did not specify an X authorization file to use, set up a temporary
# directory to house one.
if [ -z "$AUTHFILE" ]; then
@@ -147,6 +163,10 @@ XAUTHORITY=$AUTHFILE Xvfb ":$SERVERNUM" $XVFBARGS $LISTENTCP >"$ERRORFILE" \
2>&1 &
XVFBPID=$!
sleep "$STARTWAIT"
+if ! kill -0 $XVFBPID 2>/dev/null; then
+ echo "Xvfb failed to start" >&2
+ exit 1
+fi
# Start the command and save its exit status.
set +e
@@ -157,15 +177,6 @@ set -e
# Kill Xvfb now that the command has exited.
kill $XVFBPID
-# Clean up.
-XAUTHORITY=$AUTHFILE xauth remove ":$SERVERNUM" >"$ERRORFILE" 2>&1
-if [ -n "$XVFB_RUN_TMPDIR" ]; then
- if ! rm -r "$XVFB_RUN_TMPDIR"; then
- error "problem while cleaning up temporary directory"
- exit 5
- fi
-fi
-
# Return the executed command's exit status.
exit $RETVAL