I love the discussion here. This is what I had hoped for, as solution for the system, not the OP.
*** tmpfs
As a solution for the system this does not pass even preliminary considerations. This only misuses a side-effect of tmpfs to coverup the problem further. In addition it uses main memory and without any benefit from the main memory resource that is being tied up to accomplish this trick. If the same clear at shutdown was accomplished by any other means, it would serve equally as well (badly, but as well as tmpfs did). The one liner clear of /tmp/.ICE-unix does that, and the cost is so low as to be incomparable.
*** Do we blame XFCE4, or Xorg
I run XFCE4.
I shutdown almost exclusively using the desktop menu shutdown buttons. So cannot blame three-finger-salute shutdown.
I got many stale sockets, in spite of shutting down the system from the desktop.
I found reports from ubuntu and OpenBSD with identical symptoms, so they must have the same situation happening.
The startxfce4 script, as the last thing, starts the /etc/xdg/xfce4/xinitrc script.
That script as the last thing, launches the xfce4-session.
None of these scripts have anything after launching, like they never expect to be able to finish, or cleanup.
From my reading of the rc.6 script, I doubt that XFCE4 is being given the chance to shutdown cleanly.
That rc.6 script just kills any process that is left. A process that is killed that way does not have a chance to finish running any script (AFAIK). There might be a way to trigger a run-this-when-I-DIE script, but I doubt that any such has been setup (AFAIK).
I think part of the problem is due to not killing the desktop earlier in any clean manner. It seems (not verified) to be left to be killed by the mass-extinction of all processes that happens in the rc scripts, and that is leaving behind a few things uncleaned, like these stale sockets. MAYBE. There are many scripts and code not examined yet.
But, this is probably what is in common between Slackware and Ubuntu and OpenBSD.
Does that desktop menu shutdown actually shutdown anything of Xorg.
That Xorg can shutdown is evident in the Xorg log.
I have some doubt that there is anywhere, that any of the scripts or services that started Xorg are ever given a clean shutdown.
I did verify that it is Xorg that creates the ICE socket. I do not know if there is anywhere in Xorg that would remove it. That could be quite a search to find.
Because Xorg creates the socket, I would look to Xorg to clean it up afterwards.
Xorg does log shutdown events in its log, it is managing to run a shutdown. This may be the only good place to attach a fix to the desktop shutdown specifically. It probably is hard coded and not a script, so not very easy to modify or patch.
The question would be is there anywhere in XFCE scripts that a shutdown cleanup could be attached. Is it even getting any chance to cleanup itself.
There are too many ways to shutdown the system. Some of them are going to be un-clean, by their nature.
The clean up of ICE and X11 directories will have to exist. A few lines in the scripts will suffice for that.
I think what we are discussing is how much farther can be get with making XFCE4 or Xorg cleanup after themselves, too.
When, and if, the upstream Xorg maintainers will take any action is questionable.
*** My script
My script seems to work, but where I called it from was wrong.
It does not work well when called from rc.K (Because I was misled by the name, it does not get run).
It needs to be called from rc.6. Being called right after all the processes get killed provides the best effect. On my last shutdown it removed ALL the stale sockets.
I have not seen any harm when it is called from the command line, arbitrarily.
I update this only as an alternative to the discussion. Some people may need the script, such as run weekly by cron (or maybe much more often than that it sounds).
To some degree, the possible solutions may be driven by which interfere the least with the users needs. This is one reason I oppose tmpfs, it wastes resources.
The patch to rc.6.
Code:
--- orig-sw15.0/rc.6 2022-06-18 12:02:59.000000000 -0500
+++ rc.6 2023-11-05 20:53:50.172932689 -0600
@@ -208,8 +208,14 @@
echo "Sending all processes the SIGKILL signal."
/sbin/killall5 -9 $OMITPIDS
fi
+# Clean up old sockets:
+# This is most effective if done after Xorg has been killed.
+if [ -x /etc/rc.d/rc.clean_sockets ]; then
+ /etc/rc.d/rc.clean_sockets
+fi
+
# Try to turn off quota.
if /bin/grep -q quota /etc/fstab ; then
if [ -x /sbin/quotaoff -a -z "$container" ]; then
echo "Turning off filesystem quotas."
*** I wish to thank everyone for their attention to this problem.
I will shortly be buried in getting out a software release. I will try to continue investigating as time permits.