#include <sys/types.h>
#include <sys/wait.h>
-bool Q_Exec( const char *cmd, char *cmdline, const char *, bool, bool waitfor ){
+bool Q_Exec( const char *cmd, const char *cmdline, const char *, bool, bool waitfor ){
char fullcmd[2048];
char *pCmd;
pid_t pid;
#include <windows.h>
// NOTE TTimo windows is VERY nitpicky about the syntax in CreateProcess
-bool Q_Exec( const char *cmd, char *cmdline, const char *execdir, bool bCreateConsole, bool waitfor ){
+bool Q_Exec( const char *cmd, const char *cmdline, const char *execdir, bool bCreateConsole, bool waitfor ){
PROCESS_INFORMATION ProcessInformation;
STARTUPINFO startupinfo = {0};
DWORD dwCreationFlags;
else{
dwCreationFlags = DETACHED_PROCESS | NORMAL_PRIORITY_CLASS;
}
- const char *pCmd;
- char *pCmdline;
- pCmd = cmd;
+ const char *pCmd = cmd;
if ( pCmd ) {
while ( *pCmd == ' ' )
pCmd++;
}
- pCmdline = cmdline;
+ char *pCmdline = strdup(cmdline);
if ( pCmdline ) {
while ( *pCmdline == ' ' )
pCmdline++;
if ( waitfor ) {
WaitForSingleObject( ProcessInformation.hProcess, INFINITE );
}
+ free(pCmdline);
return true;
}
+ free(pCmdline);
return false;
}