From 1d7c337d60fa29d1ae8053f669c163b00d60cee4 Mon Sep 17 00:00:00 2001 From: polyphemus Date: Wed, 3 Apr 2013 11:03:55 +0200 Subject: [PATCH] Make alternative method of calling startx a configuration option. This changes the default startx call back to not using a subshell. --- src/cdm | 2 ++ src/cdm-xlaunch | 14 ++++++++++++-- src/cdmrc | 5 +++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/cdm b/src/cdm index 6ea589f..b610cbd 100755 --- a/src/cdm +++ b/src/cdm @@ -77,6 +77,7 @@ xtty=${xtty:-7} locktty=${locktty:-no} consolekit=${consolekit:-yes} cktimeout=${cktimeout:-30} +altstartx=${altstartx:-no} [[ -z "${binlist[*]}" ]] && binlist=() [[ -z "${namelist[*]}" ]] && namelist=() [[ -z "${flaglist[*]}" ]] && flaglist=() @@ -202,6 +203,7 @@ case ${flaglist[$binindex]} in serverargs=(":${display}" "${serverargs[@]}" "vt$vt") $(yesno consolekit) && launchflags=(-c -t "$cktimeout") + $(yesno altstartx) && launchflags=("${launchflags[@]}" --altstartx) if cdm-xlaunch "${launchflags[@]}" -- "${bin[@]}" -- "${serverargs[@]}" then exitnormal diff --git a/src/cdm-xlaunch b/src/cdm-xlaunch index 1f4dd7a..3d79cfd 100755 --- a/src/cdm-xlaunch +++ b/src/cdm-xlaunch @@ -31,11 +31,12 @@ name=$(basename "$0") consolekit=false cktimeout=30 +altstartx=false info() { printf ' \033[01;32m*\033[00m '; echo "$name: $*"; } error() { (printf ' \033[01;31m*\033[00m '; echo "$name: $*") > /dev/stderr; } -args=$(getopt -n "$name" -o ct: -l consolekit,timeout: -- "$@") || exit 1 +args=$(getopt -n "$name" -o ct: -l consolekit,timeout,altstartx: -- "$@") || exit 1 eval set -- "$args" for arg in "$@" do @@ -47,6 +48,9 @@ do shift cktimeout=$1; shift ;; + '--altstartx') + altstartx=true; shift + ;; '--') shift break @@ -76,7 +80,13 @@ if $consolekit; then dbuspid=$(<"$dbuspidfifo"); rm -f "$dbuspidfifo" fi -$(setsid startx "$@" > /dev/null 2>&1) & +if $altstartx; then + # Alternative method of calling setsid(/startx) for systems that are unresponsive to the 'normal' call. + # This method should be avoided because this implementation keeps extra background processes, waiting for startx to return. + $(setsid startx "$@" > /dev/null 2>&1) & +else + setsid startx "$@" > /dev/null 2>&1 & +fi # If wait(1) returns with a value >128, it was interrupted by kill(1), # so registration was sucessful. diff --git a/src/cdmrc b/src/cdmrc index 07ef72f..062fc6e 100644 --- a/src/cdmrc +++ b/src/cdmrc @@ -56,3 +56,8 @@ cktimeout=30 # Arguments with whitespaces should be quoted or escaped. serverargs=(-nolisten tcp) +# Alternative method of calling startx(/setsid). Should only be set if cdm +# does not start X as expected (bash -x shows call to setsid startx, but for +# no apparent reason does not start X). +# Only provided in the hope it proves to be useful, not a guaranteed fix. +altstartx=no