From 887174fcd312e6fce18927f93e5b0912cce59e56 Mon Sep 17 00:00:00 2001 From: Steve Checkoway Date: Fri, 26 Dec 2008 12:23:34 +0000 Subject: [PATCH] Make sure all of the crash data is written. Also silences annoying gcc warning. execve takes char *const[] as arguments so copy magic parameter. I think that is a standards bug, personally. --- stepmania/src/archutils/Unix/CrashHandler.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/stepmania/src/archutils/Unix/CrashHandler.cpp b/stepmania/src/archutils/Unix/CrashHandler.cpp index 9e45b405e1..1733907e73 100644 --- a/stepmania/src/archutils/Unix/CrashHandler.cpp +++ b/stepmania/src/archutils/Unix/CrashHandler.cpp @@ -32,7 +32,15 @@ static void safe_print( int fd, ... ) const char *p = va_arg( ap, const char * ); if( p == NULL ) break; - write( fd, p, strlen(p) ); + size_t len = strlen( p ); + while( len ) + { + ssize_t result = write( fd, p, strlen(p) ); + if( result == -1 ) + _exit( 1 ); + len -= result; + p += result; + } } va_end( ap ); } @@ -79,10 +87,12 @@ static void NORETURN spawn_child_process( int from_parent ) } char path[1024]; + char magic[32]; GetExecutableName( path, sizeof(path) ); + strncpy( magic, CHILD_MAGIC_PARAMETER, sizeof(magic) ); /* Use execve; it's the lowest-level of the exec calls. The others may allocate. */ - char *argv[3] = { path, CHILD_MAGIC_PARAMETER, NULL }; + char *argv[3] = { path, magic, NULL }; char *envp[1] = { NULL }; execve( path, argv, envp );