Don't try to write log messages to the TCP listener file descriptor
Isn't the FIXME comment about port related to command line parameters and not the logfile? Moving it inside the "if (logfile)" block makes no sense then.
Reply To cazfi
Isn't the FIXME comment about port related to command line parameters and not the logfile? Moving it inside the "if (logfile)" block makes no sense then.
Looking closer, it does make sense. No need to change the patch.
Occurred to me a bit late, but opening "/dev/null" might not work too well on Windows. Checking situation...
Reply To cazfi
Occurred to me a bit late, but opening "/dev/null" might not work too well on Windows. Checking situation...
Ok, that particular code block is not used in Windows, at least as long as msys2 or cygwin implements fork() that is good enough for freeciv's configure check.
When starting a new game from the main menu the client spawns an instance of freeciv-server. When no --log argument was specified for the client the logfile variable is NULL and client_start_server ends up closing stdout and stderr without opening any file to replace them. The next file descriptor that is allocated happens to belong to the TCP listener. lsof for the server process:
freeciv-s 824527 gunnar 0r CHR 1,3 0t0 4 /dev/null
freeciv-s 824527 gunnar 1u IPv6 1362042 0t0 TCP [::1]:farenet (LISTEN)
freeciv-s 824527 gunnar 2u IPv4 1362043 0t0 TCP 127.0.0.1:farenet (LISTEN)
freeciv-s 824527 gunnar 3u IPv6 1341307 0t0 TCP [::1]:farenet->[::1]:54822 (ESTABLISHED)
This results in further log messages to be written to the TCP listener file descriptor.