Bug#521075: updated patch
Hello!
This patch was used in Ubuntu but it caused several problems (Ubuntu
bugs 357338 and 481591.) I've reworked it again, and hopefully this is
correct now. I've validated it with both:
(basic function)
/tmp/xvfb-run -a -e /dev/stderr -s "-extension GLX" true
and:
(concurrent runs)
/tmp/xvfb-run -a -e /dev/stderr -s "-extension GLX" -- \
xterm -e 'echo $DISPLAY >> /tmp/testing.log' & \
/tmp/xvfb-run -a -e /dev/stderr -s "-extension GLX" -- \
xterm -e 'echo $DISPLAY >> /tmp/testing.log
Please see attached...
--
Kees Cook @debian.org
--- xorg-server-1.6.0/debian/local/xvfb-run~ 2009-11-13 16:22:03.000000000 -0800
+++ xorg-server-1.6.0/debian/local/xvfb-run 2009-11-13 16:26:59.000000000 -0800
@@ -109,7 +109,7 @@
while :; do
case "$1" in
- -a|--auto-servernum) SERVERNUM=$(find_free_servernum) ;;
+ -a|--auto-servernum) SERVERNUM=$(find_free_servernum); AUTONUM="yes" ;;
-e|--error-file) ERRORFILE="$2"; shift ;;
-f|--auth-file) AUTHFILE="$2"; shift ;;
-h|--help) SHOWHELP="yes" ;;
@@ -148,22 +148,32 @@
# directory to house one.
if [ -z "$AUTHFILE" ]; then
XVFB_RUN_TMPDIR="$(mktemp -d -t $PROGNAME.XXXXXX)"
- AUTHFILE="$XVFB_RUN_TMPDIR/Xauthority"
+ # Create empty file to avoid xauth warning
+ AUTHFILE=$(tempfile -n "$XVFB_RUN_TMPDIR/Xauthority")
fi
# Start Xvfb.
MCOOKIE=$(mcookie)
-XAUTHORITY=$AUTHFILE xauth source - << EOF >>"$ERRORFILE" 2>&1
+tries=10
+while [ $tries -gt 0 ]; do
+ tries=$(( $tries - 1 ))
+ XAUTHORITY=$AUTHFILE xauth source - << EOF >>"$ERRORFILE" 2>&1
add :$SERVERNUM $XAUTHPROTO $MCOOKIE
EOF
-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
+ XAUTHORITY=$AUTHFILE Xvfb ":$SERVERNUM" $XVFBARGS $LISTENTCP >>"$ERRORFILE" 2>&1 &
+ XVFBPID=$!
+
+ sleep "$STARTWAIT"
+ if kill -0 $XVFBPID 2>/dev/null; then
+ break
+ elif [ -n "$AUTONUM" ]; then
+ # The display is in use so try another one (if '-a' was specified).
+ SERVERNUM=$(find_free_servernum)
+ continue
+ fi
+ error "Xvfb failed to start" >&2
+ exit 1
+done
# Start the command and save its exit status.
set +e
Reply to: