brought back functionality from previous builds but now cross-platform
This commit is contained in:
@@ -5,6 +5,8 @@
|
||||
#include "unistd.h"
|
||||
#include "sys/wait.h"
|
||||
#include "tier1/commandline.h"
|
||||
|
||||
CUtlVector<pid_t> g_processes;
|
||||
int IRunner::Run(CUtlString szName, CUtlVector<CUtlString>& args)
|
||||
{
|
||||
pid_t pid = fork();
|
||||
@@ -26,10 +28,13 @@ int IRunner::Run(CUtlString szName, CUtlVector<CUtlString>& args)
|
||||
if (ICommandLine::CheckParam("-fpcdebug"))
|
||||
V_printf("\n");
|
||||
execargs.AppendTail(0);
|
||||
execvp(szName, (char *const*)execargs.GetData());
|
||||
if ( execvp(szName, (char *const*)execargs.GetData()) == -1 )
|
||||
{
|
||||
V_printf("Failed to launch %s\n",szName.GetString());
|
||||
_exit(0);
|
||||
}
|
||||
}
|
||||
/* parent */
|
||||
wait(NULL);
|
||||
g_processes.AppendTail(pid);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -49,10 +54,14 @@ int IRunner::Run(CUtlString szName, CUtlString szDirectory, CUtlVector<CUtlStrin
|
||||
}
|
||||
execargs.AppendTail(0);
|
||||
chdir(szDirectory.GetString());
|
||||
execvp(szName, (char *const*)execargs.GetData());
|
||||
if ( execvp(szName, (char *const*)execargs.GetData()) == -1 )
|
||||
{
|
||||
V_printf("Failed to launch %s\n",szName.GetString());
|
||||
_exit(0);
|
||||
}
|
||||
}
|
||||
g_processes.AppendTail(pid);
|
||||
/* parent */
|
||||
wait(NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -61,3 +70,13 @@ int IRunner::Run(CUtlString szName, CUtlString szDirectory, CUtlVector<CUtlStrin
|
||||
|
||||
}
|
||||
|
||||
int IRunner::Wait( void )
|
||||
{
|
||||
for (auto &process: g_processes)
|
||||
{
|
||||
int status;
|
||||
pid_t wpid = waitpid(process, &status, 0);
|
||||
}
|
||||
g_processes = {};
|
||||
return 0;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user