Skip to content

Commit

Permalink
umu_run: use Popen.wait when waiting for subprocess
Browse files Browse the repository at this point in the history
  • Loading branch information
R1kaB3rN committed May 29, 2024
1 parent 4a3c732 commit a2df7f5
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions umu/umu_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ def run_command(command: list[str]) -> int:
c_int,
] = None
proc: Popen = None
ret: int = 0
libc: str = get_libc()

if not command:
Expand Down Expand Up @@ -406,17 +407,10 @@ def run_command(command: list[str]) -> int:
start_new_session=True,
preexec_fn=lambda: prctl(PR_SET_CHILD_SUBREAPER, 1, 0, 0, 0, 0),
)
ret = proc.wait()
log.debug("Child %s exited with wait status: %s", proc.pid, ret)

while True:
try:
wait_pid, wait_status = os.waitpid(proc.pid, 0)
log.debug(
"Child %s exited with wait status: %s", wait_pid, wait_status
)
except ChildProcessError: # No more children
break

return proc.returncode
return ret


def main() -> int: # noqa: D103
Expand Down

0 comments on commit a2df7f5

Please sign in to comment.