summaryrefslogtreecommitdiffstats
path: root/x11vnc/ssltools.h
diff options
context:
space:
mode:
Diffstat (limited to 'x11vnc/ssltools.h')
-rw-r--r--x11vnc/ssltools.h25
1 files changed, 22 insertions, 3 deletions
diff --git a/x11vnc/ssltools.h b/x11vnc/ssltools.h
index e6f82c3..ebd8683 100644
--- a/x11vnc/ssltools.h
+++ b/x11vnc/ssltools.h
@@ -911,7 +911,7 @@ char find_display[] =
" dL=\"-h\"\n"
"fi\n"
"\n"
-"# a portable, but not absolutely safe, tmp file creator\n"
+"# a portable tmp file creator\n"
"mytmp() {\n"
" tf=$1\n"
" if type mktemp > /dev/null 2>&1; then\n"
@@ -1462,7 +1462,26 @@ char create_display[] =
" fi\n"
" while [ $try -lt $sry ]\n"
" do\n"
-" if [ ! -f \"/tmp/.X${try}-lock\" ]; then\n"
+" tlock=\"/tmp/.X${try}-lock\"\n"
+" if [ -r $tlock ]; then\n"
+" if echo \"$nsout\" | grep \"/tmp/.X11-unix/X${try}[ ]*\\$\" > /dev/null; then\n"
+" :\n"
+" else\n"
+" pid=`head -n 1 $tlock 2>/dev/null | sed -e 's/[ ]//g' | grep '^[0-9][0-9]*$'`\n"
+" if [ \"X$pid\" != \"X\" ]; then\n"
+" exists=0\n"
+" if [ -d /proc/$pid ]; then\n"
+" exists=1\n"
+" elif kill -0 $pid 2>/dev/null; then\n"
+" exists=1\n"
+" fi\n"
+" if [ \"X$exists\" = \"X0\" ]; then\n"
+" rm -f $tlock\n"
+" fi\n"
+" fi\n"
+" fi\n"
+" fi\n"
+" if [ ! -f $tlock ]; then\n"
" if echo \"$nsout\" | grep \"/tmp/.X11-unix/X${try}[ ]*\\$\" > /dev/null; then\n"
" :\n"
" else\n"
@@ -1715,7 +1734,7 @@ char create_display[] =
" dL=\"-h\"\n"
"fi\n"
"\n"
-"# a portable, but not absolutely safe, tmp file creator\n"
+"# a portable tmp file creator\n"
"mytmp() {\n"
" tf=$1\n"
" if type mktemp > /dev/null 2>&1; then\n"