From 1903079f9668ccb5d0643ba7ec12080eaa4f4687 Mon Sep 17 00:00:00 2001 From: Bananymous Date: Thu, 5 Dec 2024 06:47:10 +0200 Subject: [PATCH] LibC: Fix popen to return correct return value instead of -1 --- userspace/libraries/LibC/stdio.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/userspace/libraries/LibC/stdio.cpp b/userspace/libraries/LibC/stdio.cpp index d1e118a95b..4398681bbd 100644 --- a/userspace/libraries/LibC/stdio.cpp +++ b/userspace/libraries/LibC/stdio.cpp @@ -529,11 +529,8 @@ int pclose(FILE* file) return -1; } - pid_t pid = file->pid; - (void)fclose(file); - int stat; - while (waitpid(pid, &stat, 0) != -1) + while (waitpid(file->pid, &stat, 0) == -1) { if (errno != EINTR) { @@ -541,6 +538,8 @@ int pclose(FILE* file) break; } } + + (void)fclose(file); return stat; }