diff --git a/Lib/popen2.py b/Lib/popen2.py index d6ff002a20c..8a176412f30 100644 --- a/Lib/popen2.py +++ b/Lib/popen2.py @@ -83,10 +83,11 @@ def poll(self): def wait(self): """Wait for and return the exit status of the child process.""" - pid, sts = os.waitpid(self.pid, 0) - if pid == self.pid: - self.sts = sts - _active.remove(self) + if self.sts < 0: + pid, sts = os.waitpid(self.pid, 0) + if pid == self.pid: + self.sts = sts + _active.remove(self) return self.sts