A server configured with -nostdout or sys_stdout 0 will now be able to
report bugs.
Retrieves stdio stream FDs instead of assuming they're always 0,1,2.
Fixes some comment!=code discrepancies.
Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
static char hosterrorstring2[MAX_INPUTLINE]; // THREAD UNSAFE
static qbool hosterror = false;
va_list argptr;
static char hosterrorstring2[MAX_INPUTLINE]; // THREAD UNSAFE
static qbool hosterror = false;
va_list argptr;
+ int outfd = sys.outfd;
+
+ // set output to stderr
+ sys.outfd = fileno(stderr);
// turn off rcon redirect if it was active when the crash occurred
// to prevent loops when it is a networking problem
// turn off rcon redirect if it was active when the crash occurred
// to prevent loops when it is a networking problem
+ // restore configured outfd
+ sys.outfd = outfd;
+
Host_AbortCurrentFrame();
}
Host_AbortCurrentFrame();
}
va_list argptr;
char msg[MAX_INPUTLINE];
static double recursive = -1;
va_list argptr;
char msg[MAX_INPUTLINE];
static double recursive = -1;
+ int outfd = sys.outfd;
+
+ // set output to stderr
+ sys.outfd = fileno(stderr);
va_start(argptr,fmt);
dpvsnprintf(msg,sizeof(msg),fmt,argptr);
va_start(argptr,fmt);
dpvsnprintf(msg,sizeof(msg),fmt,argptr);
PRVM_PrintState(prog, 0);
recursive = -1;
}
PRVM_PrintState(prog, 0);
recursive = -1;
}
+
+ // restore configured outfd
+ sys.outfd = outfd;
void PRVM_Crash(prvm_prog_t *prog)
{
char vabuf[1024];
void PRVM_Crash(prvm_prog_t *prog)
{
char vabuf[1024];
if (!prog->loaded)
return;
if (!prog->loaded)
return;
+ // set output to stderr
+ sys.outfd = fileno(stderr);
+
PRVM_serverfunction(SV_Shutdown) = 0; // don't call SV_Shutdown on crash
if( prog->depth > 0 )
PRVM_serverfunction(SV_Shutdown) = 0; // don't call SV_Shutdown on crash
if( prog->depth > 0 )
// reset the prog pointer
prog = NULL;
// reset the prog pointer
prog = NULL;
+
+ // restore configured outfd
+ sys.outfd = outfd;
#ifdef __ANDROID__
Sys_AllowProfiling(false);
#endif
#ifdef __ANDROID__
Sys_AllowProfiling(false);
#endif
- fcntl (0, F_SETFL, fcntl (0, F_GETFL, 0) & ~O_NONBLOCK);
+ fcntl(fileno(stdout), F_SETFL, fcntl(fileno(stdout), F_GETFL, 0) & ~O_NONBLOCK);
+ fcntl(fileno(stderr), F_SETFL, fcntl(fileno(stderr), F_GETFL, 0) & ~O_NONBLOCK);
va_list argptr;
char string[MAX_INPUTLINE];
va_list argptr;
char string[MAX_INPUTLINE];
-// change stdin to non blocking
+ // set output to blocking stderr
+ sys.outfd = fileno(stderr);
- fcntl (0, F_SETFL, fcntl (0, F_GETFL, 0) & ~O_NONBLOCK);
+ fcntl(sys.outfd, F_SETFL, fcntl(sys.outfd, F_GETFL, 0) & ~O_NONBLOCK);
#endif
va_start (argptr,error);
#endif
va_start (argptr,error);
Sys_SDL_Dialog("Engine Error", string);
Sys_SDL_Dialog("Engine Error", string);
default: sigdesc = "Yo dawg, we hit a bug while hitting a bug";
}
default: sigdesc = "Yo dawg, we hit a bug while hitting a bug";
}
+ // set output to blocking stderr
+ sys.outfd = fileno(stderr);
+#ifndef WIN32
+ fcntl(sys.outfd, F_SETFL, fcntl(sys.outfd, F_GETFL, 0) & ~O_NONBLOCK);
+#endif
+
fprintf(stderr, "\n\n\e[1;37;41m Engine Crash: %s (%d) \e[m\n", sigdesc, sig);
#if __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1
// the first two addresses will be in this function and in signal() in libc
fprintf(stderr, "\n\n\e[1;37;41m Engine Crash: %s (%d) \e[m\n", sigdesc, sig);
#if __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1
// the first two addresses will be in this function and in signal() in libc
- backtrace_symbols_fd(stackframes + 2, framecount - 2, fileno(stderr));
+ backtrace_symbols_fd(stackframes + 2, framecount - 2, sys.outfd);
#endif
fprintf(stderr, "\e[1m%s\e[m\n", engineversion);
#endif
fprintf(stderr, "\e[1m%s\e[m\n", engineversion);
Sys_SDL_Dialog("Engine Crash", sigdesc);
Sys_SDL_Dialog("Engine Crash", sigdesc);