mirror of https://gitlab.com/nakst/essence
handle errors in waitpid
This commit is contained in:
parent
3c28c5d0f5
commit
5ba1bf512c
|
@ -4652,8 +4652,16 @@ int ExternalSystemShellExecute(ExecutionContext *context, Value *returnValue) {
|
||||||
void *SystemShellExecuteWithWorkingDirectoryThread(void *_coroutine) {
|
void *SystemShellExecuteWithWorkingDirectoryThread(void *_coroutine) {
|
||||||
CoroutineState *coroutine = (CoroutineState *) _coroutine;
|
CoroutineState *coroutine = (CoroutineState *) _coroutine;
|
||||||
int status;
|
int status;
|
||||||
Assert(coroutine->externalCoroutineData.i == waitpid(coroutine->externalCoroutineData.i, &status, 0));
|
pid_t p = waitpid(coroutine->externalCoroutineData.i, &status, 0);
|
||||||
coroutine->externalCoroutineData.i = WEXITSTATUS(status) == 0;
|
|
||||||
|
if (p != coroutine->externalCoroutineData.i) {
|
||||||
|
fprintf(stderr, "waitpid returned %d\n", p);
|
||||||
|
perror("waitpid failed: ");
|
||||||
|
coroutine->externalCoroutineData.i = 0;
|
||||||
|
} else {
|
||||||
|
coroutine->externalCoroutineData.i = WEXITSTATUS(status) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
ExternalCoroutineDone(coroutine);
|
ExternalCoroutineDone(coroutine);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue