]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Wait for the process instead of busy wait loop 2826/head
authorAZero13 <gfunni234@gmail.com>
Fri, 26 Dec 2025 18:05:57 +0000 (13:05 -0500)
committerAZero13 <gfunni234@gmail.com>
Fri, 26 Dec 2025 18:54:21 +0000 (13:54 -0500)
libarchive/archive_windows.c

index e55f995c77023bfaa58bf26746536d81decf292f..34626d3b69a12954744d1751e0532d066ff7a2e7 100644 (file)
@@ -778,16 +778,18 @@ pid_t
 __la_waitpid(HANDLE child, int *status, int option)
 {
        DWORD cs;
+       DWORD wait_result;
 
-       (void)option;/* UNUSED */
-       do {
-               if (GetExitCodeProcess(child, &cs) == 0) {
-                       la_dosmaperr(GetLastError());
-                       CloseHandle(child);
-                       *status = 0;
-                       return (-1);
-               }
-       } while (cs == STILL_ACTIVE);
+       (void)option; /* UNUSED */
+       wait_result = WaitForSingleObject(child, INFINITE);
+       if (wait_result != WAIT_OBJECT_0 ||
+           GetExitCodeProcess(child, &cs) == 0)
+       {
+               la_dosmaperr(GetLastError());
+               CloseHandle(child);
+               *status = 0;
+               return (-1);
+       }
 
        CloseHandle(child);
        *status = (int)(cs & 0xff);