Package: xvfb
Version: 6.9.0.dfsg.1-4
Severity: minor

I had a minor problem on a sarge install - which turned out to be
xfonts-base not being installed and the "fixed" font not being found. 
(I would suggest a dependency but I suppose you could be using a 
font-server perhaps?)

Anyhow, I've made a small patch (attached) which checks to see that
Xvfb is still running when it tries to start the client.  It also
moves some of the cleanup code to a trap statement so that it gets
called in most circumstances (barring kill -9).

Thanks,

Adrian
--- /usr/bin/xvfb-run   2006-01-15 01:33:32.000000000 +0000
+++ /tmp/xvfb-run       2006-02-02 13:23:16.000000000 +0000
@@ -81,6 +81,19 @@
     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 @@
     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 @@
   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 @@
 # 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
 

Reply via email to