Why the 30-second pause after executing this script?

From: Kirk Strauser <kirk_at_strauser.com>
Date: Fri, 09 Apr 2004 07:25:35 -0500
One of my programs (plug: JailAdmin!  Stays crunchy in milk!) uses 'jexec'
to attach to a jail to execute /etc/rc.shutdown.  I've noticed that this
works as expected, unless its output is being piped into another program, in
which case 'sh' waits about 30 seconds after the 'exit 0' line is executed
before closing its end of the pipe.  For example:

  The command dumping to STDOUT:

    root_at_kanga:/tmp# time jexec 8 sh -x /etc/rc.shutdown
    + stty status ^T
    + trap : 2
    + trap : 3

    ...

    + kill -TERM 80521
    Terminated
    + echo .
    .
    + exit 0

    real    0m0.575s
    user    0m0.043s
    sys     0m0.195s

  The command dumping to a pipe:

    root_at_kanga:/tmp# time jexec 8 sh -x /etc/rc.shutdown | cat
    + stty status ^T
    + trap : 2
    + trap : 3

    ...

    + kill -TERM 80638
    Terminated
    + echo .
    .
    + exit 0

    real    0m30.049s
    user    0m0.070s
    sys     0m0.162s

I'm at a loss.  Why would this be?  Are there workarounds?
-- 
Kirk Strauser

"94 outdated ports on the box,
 94 outdated ports.
 Portupgrade one, an hour 'til done,
 82 outdated ports on the box."

Received on Fri Apr 09 2004 - 15:57:53 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:37:50 UTC