Tools: Fixes usage of waitpid in the face of EINTR

waitpid can return early if interrupted due to EINTR.
Loop on this case and try again.
This commit is contained in:
Ryan Houdek 2023-09-12 12:41:43 -07:00
parent 90f7937146
commit aa017116b3
2 changed files with 4 additions and 4 deletions

View File

@ -149,7 +149,7 @@ namespace Exec {
}
else {
int32_t Status{};
waitpid(pid, &Status, 0);
while (waitpid(pid, &Status, 0) == -1 && errno == EINTR);
if (WIFEXITED(Status)) {
return (int8_t)WEXITSTATUS(Status);
}
@ -192,7 +192,7 @@ namespace Exec {
}
int32_t Status{};
waitpid(pid, &Status, 0);
while (waitpid(pid, &Status, 0) == -1 && errno == EINTR);
if (WIFEXITED(Status)) {
// Return what we've read
close(fd[0]);

View File

@ -157,7 +157,7 @@ namespace SquashFS {
// Parent
// Wait for the child to exit
// This will happen with execvpe of squashmount or exit on failure
waitpid(pid, nullptr, 0);
while (waitpid(pid, nullptr, 0) == -1 && errno == EINTR);
// Check the child pipe for messages
pollfd PollFD;
@ -217,7 +217,7 @@ namespace SquashFS {
}
else {
// Wait for fusermount to leave
waitpid(pid, nullptr, 0);
while (waitpid(pid, nullptr, 0) == -1 && errno == EINTR);
// Remove the mount path
rmdir(MountFolder.c_str());