LibC: Fix popen to return correct return value instead of -1

This commit is contained in:
Bananymous 2024-12-05 06:47:10 +02:00
parent b6d0950ee9
commit 1903079f96
1 changed files with 3 additions and 4 deletions

View File

@ -529,11 +529,8 @@ int pclose(FILE* file)
return -1; return -1;
} }
pid_t pid = file->pid;
(void)fclose(file);
int stat; int stat;
while (waitpid(pid, &stat, 0) != -1) while (waitpid(file->pid, &stat, 0) == -1)
{ {
if (errno != EINTR) if (errno != EINTR)
{ {
@ -541,6 +538,8 @@ int pclose(FILE* file)
break; break;
} }
} }
(void)fclose(file);
return stat; return stat;
} }