[X2Go-Dev] Bug#630: [PATCH] Handle stale X11 lock files (Fixes: #630)

Horst Schirmeier horst at schirmeier.com
Sat Oct 4 13:15:13 CEST 2014


Remove stale X11 lock files in cases where x2goagent mysteriously
disappeared (e.g., due to kill -9 or a crash).  This fixes bug #630
(and #626, which hasn't really been fixed yet).  Tested against the
original scenario from bug #626.
---
 x2goserver/sbin/x2gocleansessions | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/x2goserver/sbin/x2gocleansessions b/x2goserver/sbin/x2gocleansessions
index eb1bd3f..3b3775b 100755
--- a/x2goserver/sbin/x2gocleansessions
+++ b/x2goserver/sbin/x2gocleansessions
@@ -171,6 +171,11 @@ elsif ($pid == 0 )
 					syslog('warning', "@sinfo[1], pid @sinfo[0] cleaning up stale X11 socket file: /tmp/.X11-unix/X$display");
 					unlink("/tmp/.X11-unix/X$display");
 				}
+				if (-e "/tmp/.X$display-lock") {
+					# remove the NX-X11 lock file (as the agent will not have managed after a kill -9)
+					syslog('warning', "@sinfo[1], pid @sinfo[0] cleaning up stale X11 lock file: /tmp/.X$display-lock");
+					unlink("/tmp/.X$display-lock");
+				}
 				syslog('debug', "@sinfo[1]: unmounting all shares");
 				system( "su", "@sinfo[11]", "-c", "export HOSTNAME && x2goumount-session @sinfo[1]");
 			}
@@ -184,6 +189,12 @@ elsif ($pid == 0 )
 					syslog('warning', "@sinfo[1], pid @sinfo[0] cleaning up stale X11 socket file: /tmp/.X11-unix/X$display");
 					unlink("/tmp/.X11-unix/X$display");
 				}
+				if (-e "/tmp/.X$display-lock") {
+					# remove the NX-X11 lock file (we don't know how the agent disappeared,
+					# someone might have shot it with kill -9)
+					syslog('warning', "@sinfo[1], pid @sinfo[0] cleaning up stale X11 lock file: /tmp/.X$display-lock");
+					unlink("/tmp/.X$display-lock");
+				}
 				syslog('debug', "@sinfo[1], pid @sinfo[0] does not exist, changing status from @sinfo[4] to F");
 				syslog('debug', "@sinfo[1]: unmounting all shares");
 				system("su", "@sinfo[11]", "-c", "export HOSTNAME && x2goumount-session @sinfo[1]");
-- 
2.0.0.5.gbce14aa

-- 
PGP-Key 0xD40E0E7A
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.x2go.org/pipermail/x2go-dev/attachments/20141004/a92ecf2c/attachment.pgp>


More information about the x2go-dev mailing list