@ -4,7 +4,7 @@
# include "log.h"
# include "log.h"
# include "str_util.h"
# include "str_util.h"
HANDLE cmd_execute ( const char * path , const char * const argv [ ] ) {
int cmd_execute ( const char * path , const char * const argv [ ] , HANDLE * handle ) {
STARTUPINFO si ;
STARTUPINFO si ;
PROCESS_INFORMATION pi ;
PROCESS_INFORMATION pi ;
memset ( & si , 0 , sizeof ( si ) ) ;
memset ( & si , 0 , sizeof ( si ) ) ;
@ -18,7 +18,8 @@ HANDLE cmd_execute(const char *path, const char *const argv[]) {
size_t ret = xstrjoin ( cmd , argv , ' ' , sizeof ( cmd ) ) ;
size_t ret = xstrjoin ( cmd , argv , ' ' , sizeof ( cmd ) ) ;
if ( ret > = sizeof ( cmd ) ) {
if ( ret > = sizeof ( cmd ) ) {
LOGE ( " Command too long (% " PRIsizet " chars) " , sizeof ( cmd ) - 1 ) ;
LOGE ( " Command too long (% " PRIsizet " chars) " , sizeof ( cmd ) - 1 ) ;
return NULL ;
* handle = NULL ;
return - 1 ;
}
}
# ifdef WINDOWS_NOCONSOLE
# ifdef WINDOWS_NOCONSOLE
@ -27,10 +28,12 @@ HANDLE cmd_execute(const char *path, const char *const argv[]) {
int flags = 0 ;
int flags = 0 ;
# endif
# endif
if ( ! CreateProcess ( NULL , cmd , NULL , NULL , FALSE , flags , NULL , NULL , & si , & pi ) ) {
if ( ! CreateProcess ( NULL , cmd , NULL , NULL , FALSE , flags , NULL , NULL , & si , & pi ) ) {
return NULL ;
* handle = NULL ;
return - 1 ;
}
}
return pi . hProcess ;
* handle = pi . hProcess ;
return 0 ;
}
}
SDL_bool cmd_terminate ( HANDLE handle ) {
SDL_bool cmd_terminate ( HANDLE handle ) {