Files
@ r2280:70feb404746f
Branch filter:
Location: cpp/openttd-patchpack/source/dedicated.c - annotation
r2280:70feb404746f
1.0 KiB
text/x-c
(svn r2804) [Translators] Updated translations to 20050804 (21 lang(s))
r2186:5ee653b1b5e1 r2186:5ee653b1b5e1 r543:efdb197f91ad r543:efdb197f91ad r543:efdb197f91ad r543:efdb197f91ad r2195:f40560511b07 r2195:f40560511b07 r2195:f40560511b07 r2159:2c706fe6b0a7 r781:13ab6b3c1f17 r2195:f40560511b07 r2195:f40560511b07 r2177:986b22f06f5d r774:3e6bfb2226bd r704:3d3131641921 r704:3d3131641921 r1406:dea1cf76323c r1406:dea1cf76323c r704:3d3131641921 r704:3d3131641921 r704:3d3131641921 r704:3d3131641921 r704:3d3131641921 r704:3d3131641921 r704:3d3131641921 r704:3d3131641921 r704:3d3131641921 r704:3d3131641921 r704:3d3131641921 r704:3d3131641921 r704:3d3131641921 r704:3d3131641921 r1626:b2bd868919b7 r704:3d3131641921 r704:3d3131641921 r704:3d3131641921 r1626:b2bd868919b7 r704:3d3131641921 r704:3d3131641921 r704:3d3131641921 r704:3d3131641921 r704:3d3131641921 r704:3d3131641921 r1406:dea1cf76323c r704:3d3131641921 r704:3d3131641921 r704:3d3131641921 r702:5b64efe4d301 r702:5b64efe4d301 r543:efdb197f91ad r543:efdb197f91ad r774:3e6bfb2226bd r543:efdb197f91ad r543:efdb197f91ad | /* $Id$ */
#include "stdafx.h"
#ifdef ENABLE_NETWORK
#if defined(UNIX) && !defined(__MORPHOS__)
#include "openttd.h"
#include "variables.h"
#include <sys/types.h>
#include <unistd.h>
void DedicatedFork(void)
{
/* Fork the program */
pid_t pid = fork();
switch (pid) {
case -1:
perror("Unable to fork");
exit(1);
case 0:
// We're the child
/* Open the log-file to log all stuff too */
_log_file_fd = fopen(_log_file, "a");
if (!_log_file_fd) {
perror("Unable to open logfile");
exit(1);
}
/* Redirect stdout and stderr to log-file */
if (dup2(fileno(_log_file_fd), fileno(stdout)) == -1) {
perror("Rerouting stdout");
exit(1);
}
if (dup2(fileno(_log_file_fd), fileno(stderr)) == -1) {
perror("Rerouting stderr");
exit(1);
}
break;
default:
// We're the parent
printf("Loading dedicated server...\n");
printf(" - Forked to background with pid %d\n", pid);
exit(0);
}
}
#endif
#else
void DedicatedFork(void) {}
#endif /* ENABLE_NETWORK */
|