remote xterm's can't open display after upgrade

Linda Walsh
Sun Dec 14 22:43:00 GMT 2014

JimE wrote:

> Hi Don,
>    I'm in the same boat.  I just upgraded cygwin and now I can't get remote xterms to 
> display on the local machine.
	Question -- Is your local machine on a closed net?

	I.e. My windows machine is on a local subnet (example: 192.168.x.y) 
that isn't
(usually) exposed to the internet.

1st thing to note, is that my win X server starts automatically
when I log into windows (well it usually does unless some "upgrade"[sic]
makes something incompat), BUT, less likely to have problems, as
I start the X-server via my *own* script in my homedir's "bin" dir.

I.e. the shortcut on my QuickLaunch Bar (yeah, running W7 and still
using that...)... has

Target:  C:\bin\bash.exe -c '"%USERPROFILE%/bin/"'

my is mostly free of non-cygwin deps, except
for a tray-message util, "notify" which lets me put up messages
if the server is already running and such.

I'll leave in the comments (mostly NOTES to self or
OLD code...)... but if you know shell script, shouldn't be
hard to modify to your use case.

Some things (like a "mount -c /") at the beginning
of the script have been added over the years to
increase robustness.

This script hasn't been "cleaned" for looking good
or best coding style, but given how often I need to
maintain or change it, I haven't been motivated.

It has disabled code that tried to start dbus, but
it didn't work reliably, so it's commented out.

Parts were rewritten to try to minimize use of non-shell,
external commands (minimize deps, efficiency).

Note 1: If you want to use this in an unsecure network,
then you need to start this through an "ssh" command to
the remote machine and not reset the DISPLAY...

Note 2: one thing this script does that the cygwin
script does not do -- it tries to read your display's
"DPI" and set the corresponding option in the X-display.

---------------------extra config file: (optional) 
---------------------bash script:

# (c) LA Walsh 2004-2014, licenced under GPLv2 and/or to nice people
#export DISPLAY=:0
#export XAPPLRESDIR=/usr/X11R6/lib/X11/app-defaults
#export XCMSDB=/usr/X11R6/lib/X11/Xcms.txt
#export XKEYSYMDB=/usr/X11R6/lib/X11/XKeysymDB
#export XNLSPATH=/usr/X11R6/lib/X11/locale

# see cygwin Xwin for more option examples
# relevant ops:
# -multiwindow = use windows manage; not w/(-rootless|-fullscreen)
# -clipboard = use built-in version (integrated w/windows)
# -unixkill = Enable Ctrl-Alt-BS as X-server shutdown cmnd
# -nowinkill = Disable Alt+F4 as a server shutdown key combination.
# -trayicon = (default) windows tray icon enabled

mount -c /
export PATH=/bin:$(/bin/cygpath "$USERPROFILE")/bin:$PATH #ensure our 
bin is 1st
shopt -s expand_aliases extglob
alias notify=$(type -P notifu)
alias int=declare\ -i
alias sub=function
alias xset=$(type -P xset);
alias array=declare\ -a
alias my=declare

export DISPLAY="${DISPLAY:-":0"}"

sub xup {
   local stat
   read -t .1 stat <<<$(xset q >&/dev/null; echo $?)   &&
         return $stat
sub Xwin_pids {
   ( cd /proc  &&
       for p in +([0-9])/ ;do
         if [[ $prg =~ .*XWin ]]; then
           printf "%d:%s\n" "$p2" "$prg"

#sub Xwin_pid { echo $(/bin/ps -s|/bin/awk -- '/\?.*XWin/{print $1}') ; }

sub Xwin_pid {
   array Xprgs
   readarray Xprgs< <(Xwin_pids)
   if ((!${#Xprgs[@]}));then
     echo 0
     return 1
   my x=${Xprgs[0]}
   my pid=${x%%:**} prg=${x##*:}
   array out=( "$pid" "$prg")
   printf "%s " "${out[@]}"
   printf "\n"
   return 0

sub Xwin_running {
   int pd; my pg
   read pd pg < <(Xwin_pid)
   return $(((!pd)))
export -f Xwin_pids Xwin_pid

#sub Xwin_pid { echo $(/bin/ps -s|/bin/awk -- '/\?.*XWin/{print $1}') ; }
#export -f Xwin_pid
#sub Xwin_running { [[ $(Xwin_pid) ]] ; }
#export TERM=15 KILL=9

sub tidy_old_Xwin {
   local -a sigs=(TERM TERM KILL)  # try 2 TERMs then KILL upto maxsigs
   int pd; my pg
   int maxsigs=3 lastsig=${#sigs[*]}
   while ((1)); do
     read pd pg < <(Xwin_pid)
     ((pd)) || break
     #int i=--maxsigs>lastsig ? lastsig:maxsigs
     kill -${sigs[--maxsigs>lastsig ? lastsig:maxsigs]} $pd
     ((maxsigs)) || break
     sleep 1
   rm -fr /tmp/.X11-unix

sub get_dpi {
   dpi=$(regtool -d get '/HKLM/Software/Microsoft/Windows 
   # check for insane values
   ((dpi<50||dpi>>400)) && dpi=96
   echo "$dpi"

sub get_fontpath {
   echo -n "$fontpath"

sub start_XWin {
   int dpi=$(get_dpi)
   cmd="/bin/run /bin/XWin  ${dpi:+-dpi $dpi}
     -nomultimonitors -clipboard  -ac -unixkill -nowinkill -wgl
     -bs -fp "$fontpath" -multiwindow"
   echo cmd="$cmd"

declare -a default_switches=(-dpi -clipboard -unixkill -nowinkill -bs 
-ac -fp -multiwindow -wgl)

readarray -t args< <(
a="$default_switches[@]"; IFS=$'\n'; echo "${a[*]#?}"|sort -k1.2 )

sub read_users_mind { #(reads file in lieu of HW support for actual)
   if [[ -O ~/.mind && -O ~/.mind/Xserver-dflt-overrides ]]; then
     readarray -t overrides < <( -x
     <~/.mind/Xserver-dflt-overrides perl -wnE '
     chomp; s/\s*(?:#.*)?$//; s/^\s*// s/\s\s+/\s/ ; $_ || next;
     print $_."\n" ')
   typeset -a switches

sub  start_dbus {
   /bin/run /bin/dbus-launch --exit_with_session ~/.Xsession

sub _in {
   local x=${1:?};shift
   for ((;$#>0;)); do [[ $x == $1 ]] && return 0;shift; done
   return 1

int tries=3

if Xwin_running && xup; then
   notify /t info /m "Xserver already running and ready" /d 5000
   echo Cannot contact X Server
while ((1)); do

     start_XWin $(read_users_mind)
     sleep 1

     for ((i=0;i<5;++i)); do
       xup && break 2
       sleep 1

     if ((--tries<=0)); then
       m="EXITING: Timeout Waiting for Xserver Startup!!"
       echo "$m"
       notify /t error /m "$m"
       exit 1;
   #start_dbus || { m="Error Starting Dbus"; echo "$m"; notify /t error 
/m "$m"; }

# vim: ts=2:sw=2

Unsubscribe info:
Problem reports:

More information about the Cygwin-xfree mailing list