Fix bug with systemvpe()

See #1253
This commit is contained in:
Justine Tunney 2025-01-02 09:15:52 -08:00
parent fde03f8487
commit 8db646f6b2
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
4 changed files with 62 additions and 16 deletions

View file

@ -52,9 +52,8 @@ int systemvpe(const char *prog, char *const argv[], char *const envp[]) {
int pid, wstatus;
char pathbuf[PATH_MAX + 1];
sigset_t chldmask, savemask;
if (!(exe = commandv(prog, pathbuf, sizeof(pathbuf)))) {
if (!(exe = commandv(prog, pathbuf, sizeof(pathbuf))))
return -1;
}
sigemptyset(&chldmask);
sigaddset(&chldmask, SIGINT);
sigaddset(&chldmask, SIGQUIT);
@ -62,7 +61,7 @@ int systemvpe(const char *prog, char *const argv[], char *const envp[]) {
sigprocmask(SIG_BLOCK, &chldmask, &savemask);
if (!(pid = vfork())) {
sigprocmask(SIG_SETMASK, &savemask, 0);
execve(prog, argv, envp);
execve(exe, argv, envp);
_Exit(127);
} else if (pid == -1) {
wstatus = -1;