This commit is contained in:
vrd
2023-10-13 14:04:13 +03:00
parent 275dc6ddae
commit 11b2cef4f0
5 changed files with 22 additions and 26 deletions
+7 -11
View File
@@ -17,6 +17,13 @@ RetProc::operator bool()
return normal_exit && returned == 0;
}
RetProc wait(Proc p)
{
int status;
waitpid(p.pid, &status, 0);
return RetProc(p, status);
}
/* create a process taking input from pipe childIn */
static Proc createProc(const char* const argv[], const fd_t childIn[2])
{
@@ -169,17 +176,6 @@ Proc createProcess(const char* const argv[], fd_t in, fd_t out, fd_t err)
return proc;
}
RetProc runProcess(const char* const argv[], fd_t in, fd_t out, fd_t err)
{
Proc p = createProcess(argv, in, out, err);
// Wait to end
int status;
waitpid(p.pid, &status, 0);
return RetProc(p, status);
}
void exec_or_die(const char* const argv[])
{
execvp(argv[0], (char* const *)argv);