29 perror(
"Unable to fork");
36 perror(
"Unable to open logfile");
40 if (dup2(fileno(*
_log_fd), fileno(stdout)) == -1) {
41 perror(
"Rerouting stdout");
44 if (dup2(fileno(*
_log_fd), fileno(stderr)) == -1) {
45 perror(
"Rerouting stderr");
53 Debug(net, 0,
"Loading dedicated server...");
54 Debug(net, 0,
" - Forked to background with pid {}", pid);
static std::optional< FileHandle > Open(const std::string &filename, const std::string &mode)
Open an RAII file handle if possible.
Functions related to debugging.
#define Debug(category, level, format_string,...)
Ouptut a line of debugging information.
std::string _log_file
Filename to reroute output of a forked OpenTTD to.
std::optional< FileHandle > _log_fd
File to reroute output of a forked OpenTTD to.
Functions for Standard In/Out file operations.
A number of safeguards to prevent using unsafe methods.
Definition of base types and functions in a cross-platform compatible way.