Index: /trunk/src/VBox/Installer/linux/VBoxHeadlessXOrg.sh
===================================================================
--- /trunk/src/VBox/Installer/linux/VBoxHeadlessXOrg.sh	(revision 43687)
+++ /trunk/src/VBox/Installer/linux/VBoxHeadlessXOrg.sh	(revision 43688)
@@ -1,5 +1,5 @@
 #!/bin/sh
 #
-# VirtualBox X Server auto-start script.
+# VirtualBox X Server auto-start service.
 #
 # Copyright (C) 2012 Oracle Corporation
@@ -17,21 +17,17 @@
 
 ## Start one or several X servers in the background for use with headless
-# rendering.  We only support X.Org Server at the moment.  Starting the X
-# servers is managed by dropping one or more files xorg.conf.<n> into the
-# directory ${HEADLESS_X_ORG_CONFIGURATION_DIRECTORY} - the default value
-# below can be overridden in the configuration file.  We will attempt to start
-# an X server process for each configuration file using display number <n>.
-# For usage and options see the usage() function below this comment block.
+# rendering.  For details, options and configuration see the usage() function
+# further down.
 #
 # I have tried to follow the best practices I could find for writing a Linux
-# daemon process (and doing it in shell script) which should work well with
+# service (and doing it in shell script) which should work well with
 # traditional and modern service systems using minimal init or service files. 
 # In our case this boils down to:
 #  * Start with a single command line, stop using one of ${EXIT_SIGNALS} below.
 #  * Stopping with a signal can be done safely using the pid stored in the
-#    pid-file and our (presumably unique) command name.  For this reason we only
-#    support running one instance of the service though.
-#  * Support starting in the foreground for systems with proper service control.
-#  * Support backgrounding with a pid-file for other systems.
+#    pid-file and our (presumably unique) command name.  For this reason we
+#    only support running one instance of the service though.
+#  * Start in the foreground.  Systems without proper service control can take
+#    care of the backgrounding in the init script.
 #  * Clean up all sub-processes (X servers) ourselves when we are stopped
 #    cleanly and don't provide any other way to clean them up automatically (in
@@ -42,47 +38,6 @@
 #    using a service-specific user account and just terminate all processes
 #    run by that user to clean up.)
-#  * For this reason, our pid-file only contains the pid of the master process.
-#  * To simplify system service and start-up message handling, we write
-#    Debian-conform progress information to standard output (what processes we
-#    are starting, information if we do something slow) and errors to standard
-#    error.  This should allow us to write pretty generic init/startup scripts
-#    for different distributions which produce more-or-less correct output for
-#    the system they run on.
-
-## Print usage information for the service script.
-usage() {
-  cat << EOF
-Usage:
-
-  $(basename "${SCRIPT_NAME}") [<options>]
-
-Do any system-wide set-up required to properly run the copy of VirtualBox
-residing in the current directory.  If no options are specified, everything
-except --no-udev-and --log-file is assumed.
-
-Options:
-
-  -d|--daemonize)        Detach fron the terminal and  continue running in the
-                         background.
-
-  -l|--log-folder)       Create log files in this folder.
-
-  -p|--pidfile <name>    Specify the name of the file to save the pids of child
-                         processes in.  Pass in an empty string to disable
-                         pid-file creation.
-
-  -q|--quiet)            Do not produce unnecessary console output.  We still
-                         show a banner if the command line arguments are
-                         invalid.
-
-  --quick)               Intended for internal use.  Skip certain checks and
-                         actions at start-up and print the command line
-                         arguments to standard output.
-
-  --help|--usage         Print this text.
-EOF
-}
-
-## Configuration file name.
+
+## Default configuration file name.
 # Don't use vbox.cfg as that is currently automatically created and deleted.
 # Don't use /etc/default/virtualbox as that is Debian policy only and not very
@@ -90,5 +45,4 @@
 ## @todo Should we be using /etc/virtualbox instead of /etc/vbox?
 CONFIGURATION_FILE=/etc/vbox/vbox.conf
-
 ## The name of this script.
 SCRIPT_NAME="$0"
@@ -99,20 +53,70 @@
 ## The descriptive service name.
 SERVICE_LONG_NAME="VBoxHeadless X Server service"
-## Timeout in seconds when shutting down the service.
-SERVICE_SHUTDOWN_TIMEOUT=5
 ## Signals and conditions which may be used to terminate the service.
 EXIT_SIGNALS="EXIT HUP INT QUIT ABRT TERM"
-
-# Default settings values, override in the configuration file.
-## The directory where the configuration files for the X servers are dropped.
-HEADLESS_X_ORG_CONFIGURATION_DIRECTORY=/etc/vbox/headlessxorg.conf.d
-## The path to the pidfile for the service.
-HEADLESS_X_ORG_PID_FILE="/var/run/${SERVICE_NAME}.pid"
-## The default log folder
+## The default X server configuration directory.
+DEFAULT_CONFIGURATION_FOLDER="/etc/vbox/headlessxorg.conf.d"
+
+## Print usage information for the service script.
+## @todo Perhaps we should support some of the configuration file options from
+#        the command line.  Opinions welcome.
+## @todo Possibly extract this information for the user manual.
+usage() {
+  cat << EOF
+Usage:
+
+  $(basename "${SCRIPT_NAME}") [<options>]
+
+Start one or several X servers in the background for use with headless
+rendering.  We only support X.Org Server at the moment.  Starting the X servers
+is managed by dropping one or more files xorg.conf.<n> into a configuration
+directory (by default ${DEFAULT_CONFIGURATION_FOLDER} - this can be overridden
+in the configuration file (see below).  We will attempt to start an X server
+process for each configuration file using display number <n>.
+
+Options:
+
+  -c|--conf-file)        Specify an alternative locations for the configuration
+                         file.  The default location is \"${CONFIGURATION_FILE}\".
+
+  --help|--usage         Print this text.
+
+The optional configuration file should contain a series of lines of the form
+"KEY=value".  It will be read in as a command shell sub-script.  Here is the
+current list of possible key settings with a short explanation.
+
+  HEADLESS_X_ORG_CONFIGURATION_FOLDER
+    The folder where the configuration files for the X servers are to be found.
+
+  HEADLESS_X_ORG_LOG_FOLDER
+    The default log folder.
+
+  HEADLESS_X_ORG_LOG_FILE
+    The default log file.
+
+  HEADLESS_X_ORG_SERVER_COMMAND
+    The default X server start-up command, containing the variables "${screen}"
+    for the screen number, "${conf_file}" for the configuration file path and
+    ${log_file} for the log file.  The variables must be quoted for expansion
+    at evaluation time, e.g.
+      HEADLESS_X_ORG_SERVER_COMMAND="Xorg :\${screen} [...] > \"\${log_file}\"
+
+  HEADLESS_X_ORG_SERVER_LOG_FILE_TEMPLATE
+    The default X server log file name, containing the variable "${screen}" for
+    the screen number.  The variable must be quoted for expansion at evaluation
+    time, e.g.
+      HEADLESS_X_ORG_SERVER_LOG_FILE_TEMPLATE="Xorg.\${screen}.log"
+EOF
+}
+
+# Default configuration.
+HEADLESS_X_ORG_CONFIGURATION_FOLDER="${DEFAULT_CONFIGURATION_FOLDER}"
 HEADLESS_X_ORG_LOG_FOLDER="/var/log/${SERVICE_NAME}"
+HEADLESS_X_ORG_LOG_FILE="${SERVICE_NAME}.log"
+HEADLESS_X_ORG_SERVER_COMMAND="Xorg :\${screen} -config \"\${conf_file}\" -logverbose 0 -logfile /dev/null -verbose 7 > \"\${log_file}\" 2>&1"
+HEADLESS_X_ORG_SERVER_LOG_FILE_TEMPLATE="Xorg.\${screen}.log"
 
 ## The function definition at the start of every non-trivial shell script!
 abort() {
-  stop 2>/dev/null
   ## $@, ... Error text to output to standard error in printf format.
   printf "$@" >&2
@@ -122,5 +126,4 @@
 ## Milder version of abort, when we can't continue because of a valid condition.
 abandon() {
-  stop 2>/dev/null
   ## $@, ... Text to output to standard error in printf format.
   printf "$@" >&2
@@ -128,4 +131,10 @@
 }
 
+abort_usage() {
+  usage >&2
+  abort "$@"
+}
+
+# Print a banner message
 banner() {
   cat << EOF
@@ -135,68 +144,38 @@
 
 EOF
-[ -n "${QUICK}" ] &&
-  printf "Internal command line: ${SCRIPT_COMMAND_LINE}\n\n"
-}
-
-abort_usage() {
-  usage >&2
-  abort "$@"
-}
-
-# Change to the directory where the script is located.
-MY_DIR="$(dirname "${SCRIPT_NAME}")"
-MY_DIR=`cd "${MY_DIR}" && pwd`
-[ -d "${MY_DIR}" ] ||
-  abort "Failed to change to directory ${MY_DIR}.\n"
-
-# Get installation configuration
-[ -r /etc/vbox/vbox.cfg ] || abort "/etc/vbox/vbox.cfg not found.\n"
-. /etc/vbox/vbox.cfg
-
-[ -r scripts/generated.sh ] ||
-  abort "${LOG_FILE}" "Failed to find installation information in ${MY_DIR}.\n"
-. scripts/generated.sh
-
-[ -r /etc/vbox/vbox.conf ] && . /etc/vbox/vbox.conf
+}
+
+# Get the directory where the script is located.
+VBOX_FOLDER="$(dirname "${SCRIPT_NAME}")"
+VBOX_FOLDER=$(cd "${VBOX_FOLDER}" && pwd)
+[ -d "${VBOX_FOLDER}" ] ||
+  abort "Failed to change to directory ${VBOX_FOLDER}.\n"
+# And change to the root directory so we don't hold any other open.
+cd /
+
+[ -r "${VBOX_FOLDER}/scripts/generated.sh" ] ||
+  abort "${LOG_FILE}" "Failed to find installation information in ${VBOX_FOLDER}.\n"
+. "${VBOX_FOLDER}/scripts/generated.sh"
 
 # Parse our arguments.
 while [ "$#" -gt 0 ]; do
   case $1 in
-    -d|--daemonize)
-      DAEMONIZE=true
-      ;;
-    -l|--log-folder)
+    -c|--conf-file)
       [ "$#" -gt 1 ] ||
-        {
-          banner
-          abort "%s requires at least one argument.\n" "$1"
-        }
-      HEADLESS_X_ORG_LOG_FOLDER="$2"
+      {
+        banner
+        abort "%s requires at least one argument.\n" "$1"
+      }
+      CONFIGURATION_FILE="$2"
       shift
       ;;
-    -p|--pidfile)
-      [ "$#" -gt 1 ] ||
-        {
-          banner
-          abort "%s requires at least one argument.\n" "$1"
-        }
-      HEADLESS_X_ORG_PID_FILE="$2"
-      shift
-      ;;
-    -q|--quiet)
-      QUIET=true
-      ;;
-    --quick)
-      QUICK=true
-      ;;
     --help|--usage)
+      banner
       usage
       exit 0
       ;;
     *)
-      {
-        banner
-        abort_usage "Unknown argument $1.\n"
-      }
+      banner
+      abort_usage "Unknown argument $1.\n"
       ;;
   esac
@@ -204,47 +183,35 @@
 done
 
-[ -z "${QUIET}" ] && banner
-
-if [ -z "${QUICK}" ]; then
-  [ -f "${HEADLESS_X_ORG_PID_FILE}" ] &&
-    ps -p "$(cat "${HEADLESS_X_ORG_PID_FILE}")" -o comm |
-      grep -q "${SERVICE_NAME}" &&
-    abort "The service appears to be already running.\n"
-
-  PIDFILE_DIRECTORY="$(dirname "${HEADLESS_X_ORG_PID_FILE}")"
-  { ! [ -d "${PIDFILE_DIRECTORY}" ] || ! [ -w "${PIDFILE_DIRECTORY}" ]; } &&
-    abort "Can't write to pid-file directory \"${PIDFILE_DIRECTORY}\".\n"
-
-  # If something fails here we will catch it when we create the directory.
-  [ -e "${HEADLESS_X_ORG_LOG_FOLDER}" ] &&
-    [ -d "${HEADLESS_X_ORG_LOG_FOLDER}" ] &&
-    rm -rf "${HEADLESS_X_ORG_LOG_FOLDER}.old" 2> /dev/null &&
-    mv "${HEADLESS_X_ORG_LOG_FOLDER}" "${HEADLESS_X_ORG_LOG_FOLDER}.old" 2> /dev/null
-  mkdir -p "${HEADLESS_X_ORG_LOG_FOLDER}" 2>/dev/null ||
-    abort "Failed to create log folder \"${HEADLESS_X_ORG_LOG_FOLDER}\".\n"
-fi # -z "${QUICK}"
-
-# Double background from shell script, disconnecting all standard streams, to
-# daemonise.  This may fail if someone has connected something to another file
-# descriptor.  This is intended (see e.g. fghack in the daemontools package).
-if [ -n "${DAEMONIZE}" ]; then
-  ("${SCRIPT_NAME}" --quick -p "${HEADLESS_X_ORG_PID_FILE}" < /dev/null > "${HEADLESS_X_ORG_LOG_FOLDER}/${SERVICE_NAME}.log" 2>&1 &) &
-  ## @todo wait for the servers to start accepting connections before exiting.
-  exit 0
-fi
+[ -r "${CONFIGURATION_FILE}" ] && . "${CONFIGURATION_FILE}"
+
+# If something fails here we will catch it when we create the directory.
+[ -e "${HEADLESS_X_ORG_LOG_FOLDER}" ] &&
+  [ -d "${HEADLESS_X_ORG_LOG_FOLDER}" ] &&
+  rm -rf "${HEADLESS_X_ORG_LOG_FOLDER}.old" 2> /dev/null &&
+mv "${HEADLESS_X_ORG_LOG_FOLDER}" "${HEADLESS_X_ORG_LOG_FOLDER}.old" 2> /dev/null
+mkdir -p "${HEADLESS_X_ORG_LOG_FOLDER}" 2>/dev/null ||
+{
+  banner
+  abort "Failed to create log folder \"${HEADLESS_X_ORG_LOG_FOLDER}\".\n"
+}
+exec > "${HEADLESS_X_ORG_LOG_FOLDER}/${HEADLESS_X_ORG_LOG_FILE}" 2>&1
+
+banner
 
 X_SERVER_PIDS=""
-trap "kill \${X_SERVER_PIDS} 2>/dev/null; exit 0" ${EXIT_SIGNALS}
+trap "kill \${X_SERVER_PIDS} 2>/dev/null" ${EXIT_SIGNALS}
 space=""  # Hack to put spaces between the pids but not before or after.
-for file in "${HEADLESS_X_ORG_CONFIGURATION_DIRECTORY}"/xorg.conf.*; do
-  filename="$(basename "${file}")"
-  expr "${filename}" : "xorg.conf.[0-9]*" > /dev/null ||
-    { stop; abort "Badly formed file name \"${file}\".\n"; }
-  screen="${filename##*.}"
-  Xorg ":${screen}" -config "${file}" -logverbose 0 -logfile /dev/null -verbose 7 > "${HEADLESS_X_ORG_LOG_FOLDER}/Xorg.${screen}.log" 2>&1 &
+for conf_file in "${HEADLESS_X_ORG_CONFIGURATION_FOLDER}"/*; do
+  [ x"${conf_file}" = x"${HEADLESS_X_ORG_CONFIGURATION_FOLDER}/*" ] &&
+    ! [ -e "${conf_file}" ] &&
+    abort "No configuration files found.\n"
+  filename="$(basename "${conf_file}")"
+  screen="$(expr "${filename}" : "xorg\.conf\.\(.*\)")"
+  [ 0 -le "${screen}" ] 2>/dev/null ||
+    abort "Badly formed file name \"${conf_file}\".\n"
+  log_file="${HEADLESS_X_ORG_LOG_FOLDER}/$(eval echo "${HEADLESS_X_ORG_SERVER_LOG_FILE_TEMPLATE}")"
+  eval "${HEADLESS_X_ORG_SERVER_COMMAND}" "&"
   X_SERVER_PIDS="${X_SERVER_PIDS}${space}$!"
   space=" "
 done
-[ -n "${HEADLESS_X_ORG_PID_FILE}" ] &&
-  echo "$$" > "${HEADLESS_X_ORG_PID_FILE}"
 wait
Index: /trunk/src/VBox/Installer/linux/testcase/Makefile.kmk
===================================================================
--- /trunk/src/VBox/Installer/linux/testcase/Makefile.kmk	(revision 43687)
+++ /trunk/src/VBox/Installer/linux/testcase/Makefile.kmk	(revision 43688)
@@ -39,3 +39,9 @@
 	$(QUIET)$(CHMOD) a+rx,u+w $@
 
+INSTALLS += tstHeadlessXOrg
+TESTING += tstHeadlessXOrg
+tstHeadlessXOrg_INST    = $(INST_TESTCASE)
+tstHeadlessXOrg_MODE    = a+rx,u+w
+tstHeadlessXOrg_SOURCES = tstHeadlessXOrg.sh
+
 include $(FILE_KBUILD_SUB_FOOTER)
Index: /trunk/src/VBox/Installer/linux/testcase/tstHeadlessXOrg.sh
===================================================================
--- /trunk/src/VBox/Installer/linux/testcase/tstHeadlessXOrg.sh	(revision 43688)
+++ /trunk/src/VBox/Installer/linux/testcase/tstHeadlessXOrg.sh	(revision 43688)
@@ -0,0 +1,174 @@
+#!/bin/sh
+#
+# VirtualBox X Server auto-start service unit test.
+#
+# Copyright (C) 2012 Oracle Corporation
+#
+# This file is part of VirtualBox Open Source Edition (OSE), as
+# available from http://www.virtualbox.org. This file is free software;
+# you can redistribute it and/or modify it under the terms of the GNU
+# General Public License (GPL) as published by the Free Software
+# Foundation, in version 2 as it comes in the "COPYING" file of the
+# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+#
+
+[ x"$1" = x"--keep-temp" ] && KEEP_TEMP=true
+
+## The function definition at the start of every non-trivial shell script!
+abort()
+{
+  ## $@, ... Error text to output to standard error in printf format.
+  format="$1"
+  shift
+  printf "${TEST_NAME}: ${format}" "$@" >&2
+  exit 1
+}
+
+## Print a TESTING line.  Takes printf arguments but without a '\n'.
+print_line()
+{
+  format="$1"
+  shift
+  printf "${TEST_NAME}: TESTING ${format}... " "$@"
+}
+
+## Run a test in which VBoxHeadlessXOrg.sh is expected to complete within a
+# certain time and call a function if it does which should check whether the
+# test was successful and print status information.  The function takes the
+# exit status as its single parameter.
+run_expect_exit()
+{
+  CONF_FILE="$1"      ## The configuration file.
+  TIME_OUT="$2"       ## The time-out before we terminate the process.
+  TEST_FUNCTION="$3"  ## The function to call on exit to check the test result.
+  ./VBoxHeadlessXOrg.sh -c "${CONF_FILE}" &
+  PID=$!
+  # Give it time to complete.
+  { sleep "${TIME_OUT}"; kill "${PID}" 2>/dev/null; } &
+
+  wait "${PID}"
+  STATUS="$?"
+  case "${STATUS}" in
+  143) # SIGTERM
+    printf "\nFAILED: time-out.\n"
+    ;;
+  *)
+    ${TEST_FUNCTION} "${STATUS}"
+esac
+}
+
+# Get the directory where the script is located and change to the parent.
+VBOX_FOLDER="$(dirname "$0")/.."
+VBOX_FOLDER=$(cd "${VBOX_FOLDER}" && pwd)
+[ -d "${VBOX_FOLDER}" ] ||
+  abort "Failed to change to directory ${VBOX_FOLDER}.\n"
+cd "${VBOX_FOLDER}"
+
+# Get our name for output.
+TEST_NAME="$(basename "$0" .sh)"
+
+# Create a temporary directory for configuration and logging.
+for i in 0 1 2 3 4 5 6 7 8 9; do
+  TEST_FOLDER="/tmp/${TEST_NAME}${i}"
+  mkdir -m 0700 "${TEST_FOLDER}" 2>/dev/null && break
+done
+[ -d "${TEST_FOLDER}" ] || abort "Failed to create a temporary folder\n"
+# Clean up.  Small race here, but probably not important.
+[ -z "${KEEP_TEMP}" ] &&
+  trap "rm -r \"${TEST_FOLDER}\" 2>/dev/null" EXIT HUP INT QUIT ABRT TERM
+# Server configuration folder.
+XORG_FOLDER="${TEST_FOLDER}/xorg"
+mkdir "${XORG_FOLDER}"
+
+# Set up our basic configuration file.
+cat > "${TEST_FOLDER}/conf" << EOF
+HEADLESS_X_ORG_CONFIGURATION_FOLDER="${XORG_FOLDER}"
+HEADLESS_X_ORG_LOG_FOLDER="${TEST_FOLDER}/log"
+HEADLESS_X_ORG_LOG_FILE="log"
+HEADLESS_X_ORG_SERVER_COMMAND="echo \\\${screen} \\\${conf_file} \\\${log_file}"
+HEADLESS_X_ORG_SERVER_LOG_FILE_TEMPLATE="log.\\\${screen}"
+EOF
+
+# Simple start-up test.
+print_line "simple start-up test"
+touch "${XORG_FOLDER}/xorg.conf.2"
+touch "${XORG_FOLDER}/xorg.conf.4"
+test_simple_start_up()
+{
+  STATUS="$1"
+  case "${STATUS}" in
+  0)
+    LOG_FOLDER="${TEST_FOLDER}/log"
+    LOG="${LOG_FOLDER}/log"
+    if grep -q "2 ${XORG_FOLDER}/xorg.conf.2 ${LOG_FOLDER}/log.2" "${LOG}" &&
+      grep -q "4 ${XORG_FOLDER}/xorg.conf.4 ${LOG_FOLDER}/log.4" "${LOG}"; then
+      printf "SUCCESS.\n"
+    else
+      printf "\nFAILED: incorrect log output.\n"
+    fi
+    ;;
+  *)
+    printf "\nFAILED: exit status ${STATUS}.\n"
+  esac
+}
+run_expect_exit "${TEST_FOLDER}/conf" 5 test_simple_start_up
+rm "${XORG_FOLDER}"/xorg.conf.*
+
+# No configuration files.
+print_line "no configuration files"
+test_should_fail()
+{
+  STATUS="$1"
+  case "${STATUS}" in
+  0)
+    printf "\nFAILED: successful exit when an error was expected.\n"
+    ;;
+  *)
+    printf "SUCCESS.\n"  # At least it behaved the way we wanted.
+  esac
+}
+run_expect_exit "${TEST_FOLDER}/conf" 5 test_should_fail
+
+# Bad configuration files.
+print_line "bad configuration files"
+touch "${XORG_FOLDER}/xorg.conf.2"
+touch "${XORG_FOLDER}/xorg.conf.4"
+touch "${XORG_FOLDER}/xorg.conf.other"
+run_expect_exit "${TEST_FOLDER}/conf" 5 test_should_fail
+rm "${XORG_FOLDER}/"xorg.conf.*
+
+# Set up a configuration file for a long-running command.
+cat > "${TEST_FOLDER}/conf" << EOF
+HEADLESS_X_ORG_CONFIGURATION_FOLDER="${XORG_FOLDER}"
+HEADLESS_X_ORG_LOG_FOLDER="${TEST_FOLDER}/log"
+HEADLESS_X_ORG_LOG_FILE="log"
+HEADLESS_X_ORG_SERVER_COMMAND="echo $$ > ${TEST_FOLDER}/pid.\\\${screen}; cat"
+HEADLESS_X_ORG_SERVER_LOG_FILE_TEMPLATE="log.\\\${screen}"
+EOF
+
+# Long running server command.
+print_line "long running server command"
+touch "${XORG_FOLDER}/xorg.conf.1"
+touch "${XORG_FOLDER}/xorg.conf.5"
+FAILURE=""
+./VBoxHeadlessXOrg.sh -c "${TEST_FOLDER}/conf"
+PID="$!"
+[ -r "${TEST_FOLDER}/pid.1" ] &&
+  [ -r "${TEST_FOLDER}/pid.5" ] &&
+  ps -p "$(cat "${TEST_FOLDER}/pid.1")" >/dev/null 2>&1 &&
+  ps -p "$(cat "${TEST_FOLDER}/pid.5")" >/dev/null 2>&1 ||
+  FAILURE="\nFAILED to start servers.\n"
+[ -n "${PID}" ] && kill "${PID}"
+{ [ -r "${TEST_FOLDER}/pid.1" ] &&
+    ps -p "$(cat "${TEST_FOLDER}/pid.1")" >/dev/null 2>&1; } ||
+{ [ -r "${TEST_FOLDER}/pid.5" ] &&
+    ps -p "$(cat "${TEST_FOLDER}/pid.5")" >/dev/null 2>&1; } &&
+  FAILURE="\nFAILED to stop servers.\n"  # To terminate or not to terminate?
+if [ -z "${FAILURE}" ]; then
+  printf "${FAILURE}"
+else
+  printf "SUCCESS.\n"
+fi
+rm "${XORG_FOLDER}/"xorg.conf.*
+rm -f "${TEST_FOLDER}/pid.1" "${TEST_FOLDER}/pid.5"
