Revision: 4271
http://tigervnc.svn.sourceforge.net/tigervnc/?rev=4271&view=rev
Author: dcommander
Date: 2011-02-09 08:24:58 +0000 (Wed, 09 Feb 2011)
Log Message:
-----------
Port -list feature and -kill robustifications from TurboVNC 1.0
Modified Paths:
--------------
trunk/unix/vncserver
Modified: trunk/unix/vncserver
===================================================================
--- trunk/unix/vncserver 2011-02-09 08:08:14 UTC (rev 4270)
+++ trunk/unix/vncserver 2011-02-09 08:24:58 UTC (rev 4271)
@@ -1,5 +1,6 @@
#!/usr/bin/env perl
#
+# Copyright (C) 2009-2010 D. R. Commander. All Rights Reserved.
# Copyright (C) 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
# Copyright (C) 2002-2003 Constantin Kaplinsky. All Rights Reserved.
# Copyright (C) 2002-2005 RealVNC Ltd.
@@ -121,12 +122,14 @@
# Check command line options
&ParseOptions("-geometry",1,"-depth",1,"-pixelformat",1,"-name",1,"-kill",1,
- "-help",0,"-h",0,"--help",0,"-fp",1);
+ "-help",0,"-h",0,"--help",0,"-fp",1,"-list",0);
&Usage() if ($opt{'-help'} || $opt{'-h'} || $opt{'--help'});
&Kill() if ($opt{'-kill'});
+&List() if ($opt{'-list'});
+
# Uncomment this line if you want default geometry, depth and pixelformat
# to match the current X display:
# &GetXDisplayDefaults();
@@ -525,11 +528,32 @@
" [-pixelformat rgbNNN|bgrNNN]\n".
" [-fp <font-path>]\n".
" <Xvnc-options>...\n\n".
- " $prog -kill <X-display>\n\n");
+ " $prog -kill <X-display>\n\n".
+ " $prog -list\n\n");
}
#
+# List
+#
+
+sub List
+{
+ opendir(dir, $vncUserDir);
+ my @filelist = readdir(dir);
+ closedir(dir);
+ print "\nTurboVNC server sessions:\n\n";
+ print "X DISPLAY #\tPROCESS ID\n";
+ foreach my $file (@filelist) {
+ if ($file =~ /$host:(\d+)$\.pid/) {
+ print ":".$1."\t\t".`cat $vncUserDir/$file`;
+ }
+ }
+ exit 1;
+}
+
+
+#
# Kill
#
@@ -555,7 +579,33 @@
$SIG{'HUP'} = 'IGNORE';
chop($pid = `cat $pidFile`);
warn "Killing Xvnc process ID $pid\n";
- system("kill $pid");
+
+ if (kill 0, $pid) {
+ system("kill $pid");
+ sleep(1);
+ if (kill 0, $pid) {
+ print "Xvnc seems to be deadlocked. Kill the process manually and
then re-run\n";
+ print " ".$0." -kill ".$opt{'-kill'}."\n";
+ print "to clean up the socket files.\n";
+ exit
+ }
+
+ } else {
+ warn "Xvnc process ID $pid already killed\n";
+ $opt{'-kill'} =~ s/://;
+
+ if (-e "/tmp/.X11-unix/X$opt{'-kill'}") {
+ print "Xvnc did not appear to shut down cleanly.";
+ print " Removing /tmp/.X11-unix/X$opt{'-kill'}\n";
+ unlink "/tmp/.X11-unix/X$opt{'-kill'}";
+ }
+ if (-e "/tmp/.X$opt{'-kill'}-lock") {
+ print "Xvnc did not appear to shut down cleanly.";
+ print " Removing /tmp/.X$opt{'-kill'}-lock\n";
+ unlink "/tmp/.X$opt{'-kill'}-lock";
+ }
+ }
+
unlink $pidFile;
exit;
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
Tigervnc-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tigervnc-commits