From 52ead6fa36d2479f9337b159f6875c075878717b Mon Sep 17 00:00:00 2001 From: Tim Angus Date: Wed, 30 Mar 2011 21:58:31 +0000 Subject: [PATCH] * Crash recovery for com_pipeFile (Lakitu7) --- code/qcommon/files.c | 2 ++ code/sys/sys_unix.c | 11 ++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/code/qcommon/files.c b/code/qcommon/files.c index 3256b449..f6d8e3df 100644 --- a/code/qcommon/files.c +++ b/code/qcommon/files.c @@ -943,6 +943,8 @@ fileHandle_t FS_FCreateOpenPipeFile( const char *filename ) { } else { + Com_Printf( S_COLOR_YELLOW "WARNING: Could not create new com_pipefile at %s. " + "com_pipefile will not be used.\n", ospath ); f = 0; } diff --git a/code/sys/sys_unix.c b/code/sys/sys_unix.c index af9d59a2..a6b1931a 100644 --- a/code/sys/sys_unix.c +++ b/code/sys/sys_unix.c @@ -254,9 +254,14 @@ Sys_Mkfifo */ FILE *Sys_Mkfifo( const char *ospath ) { - FILE *fifo; - int result; - int fn; + FILE *fifo; + int result; + int fn; + struct stat buf; + + // if file already exists AND is a pipefile, remove it + if( !stat( ospath, &buf ) && S_ISFIFO( buf.st_mode ) ) + FS_Remove( ospath ); result = mkfifo( ospath, 0600 ); if( result != 0 )