[SOLVED] startxfce4 finds DISPLAY is already set, on freshly booted system
Linux - DesktopThis forum is for the discussion of all Linux Software used in a desktop context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
startxfce4 finds DISPLAY is already set, on freshly booted system
This is an intermittent problem. It can happen 2 times out of 7 startx.
When "startx" is invoked, sometime xfce4 start finds that DISPLAY is already set, and errors out, wrongly.
I have added the following instrumentation to the startxfce4 file, to log the problem.
It has been inserted to execute where the script finds that DISPLAY is already set.
Code:
function debug_dump
{
local log=~/startxfce4.log
echo "DEBUG_DUMP: $0" | tee >> $log
echo "DISPLAY=($DISPLAY)=" | tee >> $log
echo "OPT param=$*" | tee >> $log
echo "XFCE4_SESSION_WITH_CK=$XFCE4_SESSION_WITH_CK" | tee >> $log
echo "SERVERRC=$SERVERRC" | tee >> $log
echo "CLIENTRC=$CLIENTRC" | tee >> $log
echo "XDG_CONFIG_HOME=$XDG_CONFIG_HOME" | tee >> $log
echo "BASEDIR=$BASEDIR" | tee >> $log
echo "XDG_DATA_DIRS=$XDG_DATA_DIRS" | tee >> $log
echo "XDG_CONFIG_DIRS=$XDG_CONFIG_DIRS" | tee >> $log
echo "DISPLAY=$DISPLAY" | tee >> $log
echo "XDG_VTNR=$XDG_VTNR" | tee >> $log
echo "END_LOG\n"
}
It left this as a log today when startx failed again.
It appears there are two sessions logged.
Note that the first DISPLAY line uses =( )= as delimiters, the second does not.
startxfce4.log:
I have tried clearing it in /etc/profile
DISPLAY=
and that did not help.
DISPLAY was in an export stmt in /etc/profile, and currently that line has been edited to exclude DISPLAY from export. It is not set anywhere in /etc/profile anyway.
As this is first login after booting the system, where could it possibly be getting some value for DISPLAY ?
I want to check this location at shutdown, so I have to find out where it is kept.
I suspect there is not supposed to be one, but then I am back to question1.
When startx is tried a second time, it has succeeded.
After finding it set during the first failure, how is it finding DISPLAY to be cleared in the second.
I do not see any place where it is being cleared.
Where are system environmental variables set, how many are there.
If this was a user local environmental variable, I expect it would be more consistent, not so erratic.
Also, this is happening for two different users.
/etc/lynx.cfg:.h2 DISPLAY_CHARSET_CHOICE
/etc/lynx.cfg:# DISPLAY_CHARSET_CHOICE and ASSUMED_DOC_CHARSET_CHOICE settings correspondingly.
/etc/lynx.cfg:#DISPLAY_CHARSET_CHOICE:*
/etc/lynx.cfg:# enabled if DISPLAY environment variable IS defined and
/etc/lynx.cfg:# then printer/downloader will be enabled if DISPLAY
/etc/lynx.cfg:# for viewing image content types when the DECW$DISPLAY logical
/etc/lynx.cfg:# viewing image content types when the DISPLAY environment variable
/etc/lynx.cfg:# defined when the user has the environment variable DISPLAY
/etc/lynx.cfg:# (DECW$DISPLAY on VMS) defined. If the NON_XWINDOWS environment
/etc/lynx.cfg:# user DOES NOT have the environment variable DISPLAY defined.
/etc/lynx.cfg:# variable DISPLAY defined *at program start*, and equivalent to FALSE
/etc/lynx.cfg:# $DISPLAY environment variable is set, else if NON_XWINDOWS then command
/etc/lynx.cfg:# is allowed only if $DISPLAY environment variable is not set, if absent or
/etc/lynx.cfg:#ENABLE_LYNXRC:DISPLAY:OFF
/etc/profile:# DISPLAY, May be fooling startx into thinking that x-windows is already running
/etc/profile:#export PATH DISPLAY LESS TERM PS1 PS2
/etc/slrn.rc:% WWW browser to use. Xbrowser is used when the DISPLAY environment variable
/etc/termcap:######## LCD DISPLAYS
/etc/termcap:# DISPLAY FUNCTION GROUP III
/etc/termcap:# This must be used with DISPLAY FUNCTION GROUP I or III
/etc/postfix/main.cf.default:import_environment = MAIL_CONFIG MAIL_DEBUG MAIL_LOGTAG TZ XAUTHORITY DISPLAY LANG=C POSTLOG_SERVICE POSTLOG_HOSTNAME
/etc/security/pam_env.conf:# Set the DISPLAY variable if it seems reasonable
/etc/security/pam_env.conf:#DISPLAY DEFAULT=${REMOTEHOST}:0.0 OVERRIDE=${DISPLAY}
>> grep DISPLAY /etc/rc.d/*
was empty. Did not find anything.
Last edited by selfprogrammed; 09-10-2023 at 05:18 PM.
I have modified my dump by adding a date, and including the message from startxfce4, so I know which path it took.
Modified test again, putting a call to the dump into the "success" path, and one in the "fail" path.
This starts a x-windows session, in spite of failing the DISPLAY test.
What is weird, is I thought that the other user was running on "DISPLAY=:0".
I have tracked down the $DISPLAY, but not why it gets set wrong.
DISPLAY gets set by the /usr/bin/startx script.
According to the man page for startx, it is set and NEVER READ.
Startx determines DISPLAY from the following bit of script.
Code:
# Automatically determine an unused $DISPLAY
d=0
while true ; do
[ -e "/tmp/.X$d-lock" -o -S "/tmp/.X11-unix/X$d" ] || break
d=$(($d + 1))
done
defaultdisplay=":$d"
unset d
One of the arguments to startx can set the display.
The bad indenting here is in the original.
Code:
*)
if [ "$whoseargs" = "client" ]; then
clientargs="$clientargs $1"
else
# display must be the FIRST server argument
if [ x"$serverargs" = x ] && \
expr "$1" : ':[0-9][0-9]*$' > /dev/null 2>&1; then
display="$1"
else
serverargs="$serverargs $1"
fi
fi
;;
Finally:
Code:
# if no display, use default
if [ x"$display" = x ]; then
display=$defaultdisplay
fi
Later it gets used:
Code:
authdisplay=${display:-:0}
Conditionally, if enable_xauth then there are more complications, but I have not determined if that bit is even invoked.
At the top of this is this line
Code:
# Site administrators are STRONGLY urged to write nicer versions.
Does anyone know of anybody who writes their own "nicer" startx. What guidelines would they use.
So, it would seem that x-windows shutdown is leaving behind lock files.
/tmp/.X0-lock
/tmp/.X11-unix/X0
The DISPLAY problem, is completely bogus.
I got the startx and startxfce4 scripts instrumented, so the next time the startx fails, I would have a log of what exactly happened.
It was when I also enabled saving logs from a successful startup (it is intermittent), that I noticed that it ALWAYS finds DISPLAY is already set, and ALWAYS puts out that message that X is already running.
Tracked it down to the startx script, which sets DISPLAY entirely according to lock files kept in /tmp.
Any other setting or clearing of DISPLAY would be irrelevant.
If there were not lock files already present, its next actions would create them.
The message is misleading, as it looks like an error message, but is not.
If the user executes startxfce4 directly, then it will discover that DISPLAY is not set, and that X needs to be started. So then it will execute xinit, which does that.
If the user executes startx directly, it starts X, and then executes the default window manager, which it starts using startxfce4.
The DISPLAY variable is just the communication between them.
The failing of startx, which I am experiencing, must then have something to do with the ICE messages which follow afterwards.
I have yet to diagnose those.
They are not getting recorded in any logs that I can find, yet, and I don't have any saved, yet.
As the this no longer has anything to do with DISPLAY, I am marking the original problem as solved, even though I still have the intermittent failure of startx.
Last edited by selfprogrammed; 09-22-2023 at 06:03 PM.
I have found the cause of the problems, but should discuss how to fix on Slackware.
I have tried to post a thread for this but keep getting blocked by CloudFlare.
I have tried getting the thread moved, but am ignored on that. Total silence, I think the moderator is distracted or mad at me or something.
Have you tried deleting linuxquestions.org cookies? What about adding it to, or removing it from, /etc/hosts? Cloudfare blocking hasn't happened here in at least a year. I have multiple browsers installed. When a site won't work in one, I try another.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.