It's useful to be able to know the exit code of the process when it
fails with a non-zero exit code.
To get this to work, I had to fix a bug in the implementation of
check_output. Previously, check_output would call both p.communicate()
and p.poll(). The former has the effect of waiting for EOF on the
input and then waiting for the child to exit, reaping it with
waitpid(2). Unfortunately, p.poll() was hoping to be able to also
use waitpid(2) to retrieve the exit code of the process. But since the
child had already been reaped, the given pid no longer existed, and thus
waitpid(2) would return ECHILD.
Luckily the call to p.poll() is unnecessary, as the process already
provides p.retcode() for retrieving the exit code.
It's useful to be able to know the exit code of the process when it fails with a non-zero exit code.
To get this to work, I had to fix a bug in the implementation of check_output. Previously, check_output would call both
p.communicate()
andp.poll()
. The former has the effect of waiting for EOF on the input and then waiting for the child to exit, reaping it withwaitpid(2)
. Unfortunately,p.poll()
was hoping to be able to also usewaitpid(2)
to retrieve the exit code of the process. But since the child had already been reaped, the given pid no longer existed, and thuswaitpid(2)
would returnECHILD
.Luckily the call to
p.poll()
is unnecessary, as the process already providesp.retcode()
for retrieving the exit code.