From bc54f752263500323a6f9e6af21981c1c1343447 Mon Sep 17 00:00:00 2001 From: Dmitry Maksyoma Date: Sun, 1 Aug 2021 22:36:58 +1200 Subject: [PATCH] vncserver: extract IfXvncDidntStartTryFixingFontPathAndStartXvncAgain() --- unix/vncserver | 43 ++++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/unix/vncserver b/unix/vncserver index 6baea2f..6107fb3 100755 --- a/unix/vncserver +++ b/unix/vncserver @@ -114,26 +114,10 @@ $pidFile = "$vncUserDir/$host:$displayNumber.pid"; &StartXAndRecordPID(); # Give Xvnc a chance to start up - sleep(3); -if ($fontPath ne $defFontPath) { - unless (kill 0, `cat $pidFile`) { - if ($fpArgSpecified) { - warn "\nWARNING: The first attempt to start Xvnc failed, probably because the font\n"; - warn "path you specified using the -fp argument is incorrect. Attempting to\n"; - warn "determine an appropriate font path for this system and restart Xvnc using\n"; - warn "that font path ...\n"; - } else { - warn "\nWARNING: The first attempt to start Xvnc failed, possibly because the font\n"; - warn "catalog is not properly configured. Attempting to determine an appropriate\n"; - warn "font path for this system and restart Xvnc using that font path ...\n"; - } - $cmd =~ s@-fp [^ ]+@@; - $cmd .= " -fp $defFontPath" if ($defFontPath); - &StartXAndRecordPID(); - sleep(3); - } -} + +&IfXvncDidntStartTryFixingFontPathAndStartXvncAgain(); + unless (kill 0, `cat $pidFile`) { warn "Could not start Xvnc.\n\n"; unlink $pidFile; @@ -943,3 +927,24 @@ sub ConstructXvncCmd { sub StartXAndRecordPID { system("$cmd & echo \$! >$pidFile"); } + +sub IfXvncDidntStartTryFixingFontPathAndStartXvncAgain { + if ($fontPath ne $defFontPath) { + unless (kill 0, `cat $pidFile`) { + if ($fpArgSpecified) { + warn "\nWARNING: The first attempt to start Xvnc failed, probably because the font\n"; + warn "path you specified using the -fp argument is incorrect. Attempting to\n"; + warn "determine an appropriate font path for this system and restart Xvnc using\n"; + warn "that font path ...\n"; + } else { + warn "\nWARNING: The first attempt to start Xvnc failed, possibly because the font\n"; + warn "catalog is not properly configured. Attempting to determine an appropriate\n"; + warn "font path for this system and restart Xvnc using that font path ...\n"; + } + $cmd =~ s@-fp [^ ]+@@; + $cmd .= " -fp $defFontPath" if ($defFontPath); + &StartXAndRecordPID(); + sleep(3); + } + } +}