Bug#855999: Pbuilder hangs until timeout when output is piped

Yuri Gribov tetra2005 at gmail.com
Fri Feb 24 07:01:00 UTC 2017


Package: pbuilder
Version: 0.223

Hi,

When using --timeout option of pbuilder and piping output to e.g. cat,
pbuilder will hang until timeout expires (instead of terminating once
build is done):

$ sudo pbuilder build --timeout 1h  lua5.2_5.2.4-1ubuntu1.dsc 2>&1 | cat
...
I: Copying back the cached apt archive contents
I: unmounting dev/pts filesystem
I: unmounting run/shm filesystem
I: unmounting proc filesystem
I: cleaning the build env
I: removing directory /var/cache/pbuilder/build/5322 and its subdirectories
I: Current time: Fri Feb 24 06:57:25 GMT 2017
I: pbuilder-time-stamp: 1487919445  # <-- Hangs for 1 hour

It seems that the issue is in /usr/lib/pbuilder/pbuilder-buildpackage :

if [ -n "${TIMEOUT_TIME}" ]; then
    (
        : Timeout process
        sleep "${TIMEOUT_TIME}"
        log.i "Terminating build process due to timeout "
        kill "${BUILD_PID}" || true
    ) & # timeout process
    KILL_WAIT_PID="kill $! || true; echo \"I: Terminate timeout process\"; "
...
    eval "${KILL_WAIT_PID}"

Note that KILL_WAIT_PID will kill the parent shell but keep sleep
running. Sleep child process will become a zombie and keep writing to
pipe which will _probably_ prevent it from being reaped by the kernel.

A simple fix which worked for me is to redirect sleep's output to
/dev/null (both stdout and stderr need to be redirected):

        sleep "${TIMEOUT_TIME}" &> /dev/null

As far as I can see, the issue is still present in latest pbuilder.

-Iurii



More information about the Pbuilder-maint mailing list