ValveSoftware / halflife

Half-Life 1 engine based games
Other
3.57k stars 596 forks source link

The hlds_run script hangs when it is supposed to restart the server #3689

Open MegaBrutal opened 5 months ago

MegaBrutal commented 5 months ago

When the server crashes, hlds_run attempts to create a bug report before restarting the server. Instead, it hangs. The reason for this is tries to cat the pidfile in the following lines.

   191              # check to see if a core was dumped
   192              if test -f core ; then
   193                  CORE="core"
   194              elif test -f core.`cat $PID_FILE`; then
   195                  CORE=core.`cat $PID_FILE`
   196              elif test -f "$HL.core" ; then
   197                  CORE="$HL.core"
   198              fi

The problem is that PID_FILE is not always defined (despite the script tries to ensure that). When it is unset, cat ends up being called without arguments so it reads from the standard input, effectively hanging the script. Killing the cat process lets the script advance.

I'd generally suggest to revise the script by modern standards and use shellcheck to uncover potential issues.