sys: allow the platform to handle crashes after DP does As suggested by divVerent in chat. In SDL builds (including when using -dedicated on the cmdline) the OS handler runs after the user clicks OK on the SDL dialog. Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
Make the Sys_Error() message more informative Re: 24550510e6ff331c1749707df7fad608f618bdd3 as discussed in chat, there was a good reason to change this word: it indicates DP deliberately stopped execution, whereas "Error" is generic (most problems that can happen on a computer are some form of error). Also "Engine Error" makes it sound like there's a bug in DP, which isn't necessarily the case: there are several scenarios where user error can trigger this. This message was already different from Quake's "Quake Error". Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
Revert renamings from 591877ee0c64958303dcbb4f2af3d343a420cf6a Pragmatically speaking, absent any good reason otherwise, naming conventions for functions like Sys_Error should remain consistent with Quake for developer sanity.
sys: prevent loops in signal handlers Fixes https://gitlab.com/xonotic/xonotic/-/issues/377 Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
Fix some mingw warnings Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
sys: refactor the clean shutdown process After all the other refactors finally we can clean this up. Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
sys: improve error and crash handling Renames Sys_Error to Sys_Abort (now using the Engine Abort message) for clarity (as distinct from the non-fatal Host_Error). Includes the engine version in the Crash and Abort SDL dialogs. Linux: includes the glibc backtrace in the Engine Crash SDL dialog. Fixes CTRL+C not working while the SDL dialog is open. Fixes a double Sys_Error/Sys_Abort when memory corruption was detected. Windows: omits colours when printing a Crash to stderr (not supported). Makes signal handling (mostly) POSIX async-signal-safe. Fixes a slight bug in PRVM_ShortStackTrace(). Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
sys: optimise printing to stdout Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
com: rename BSD strlcpy and strlcat The C standard reserves str* and mem* for the implementation. Checking for BSD or OS X is not a robust way to determine if libc provides these (eg glibc may implement them). Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
sys: attempt to placate Microsoft's compiler Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
sys: write significant engine and QC errors to stderr 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>
sys: make stdout/stderr configurable during runtime Adds cvar sys_stdout which offers the same behaviours as the -nostdout and -stderr cmdline options and is initialised by them if they're passed. Makes -noterminal cmdline option a synonym for -nostdout, previously it was effectively the same but less efficient. Platforms with the fcntl() syscall (ie non-Windows): Changes to non-blocking stdout/stderr by default to prevent stutters and halts in certain scenarios. Adds cvar sys_stdout_blocks for enabling blocking stdout/stderr if required. Retrieves stdio stream FDs instead of assuming they're always 0,1,2. Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
sys: implement signal handling on all platforms Prints a stack trace when crashing if using glibc. Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
cmd: fix stdin command ordering and related stuff Fixes bug introduced in d217d6b9ba9012bc374ac0d44d48422b7b13b755 where multiline stdin execution order was reversed. Retrieves FD of stdin stream rather than assuming it will always be 0. Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
sys: commenting and tidying Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
deduplicate Sys_Shutdown() Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
deduplicate Sys_Print() Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
deduplicate Sys_Error() Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
deduplicate Sys_ConsoleInput() Fixes multiline stdin not working in the SDL client, but working in the dedicated server. Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
deduplicate main() Signed-off-by: bones_was_here <bones_was_here@xonotic.au>