bin/66242: endless loop in sh(1)

Bruce Evans bde at zeta.org.au
Tue May 4 10:35:34 PDT 2004


On Tue, 4 May 2004, Dmitry Sivachenko wrote:

> The following sh(1) behaviour can be observed on both -CURRENT and -STABLE.
>
> >Description:
> Consider the following script:
>
> #!/bin/sh -T
>
> trap 'echo TRAP!; ps; exit 1' HUP;
>
> echo 'Started...'
> read a
>
>
> Run it and send HUP signal to sh(1) while it is waiting for 'read' command.
> You reach trap handler, ps(1) output appears but the script does NOT exit
> and sh(1) process starts to eat 100% of CPU.
>
> Here is truss output:
> wait4(0xffffffff,0xbfbfe9d8,0x2,0x0)             ERR#10 'No child processes'
> wait4(0xffffffff,0xbfbfe9d8,0x2,0x0)             ERR#10 'No child processes'
> wait4(0xffffffff,0xbfbfe9d8,0x2,0x0)             ERR#10 'No child processes'
> wait4(0xffffffff,0xbfbfe9d8,0x2,0x0)             ERR#10 'No child processes'
> wait4(0xffffffff,0xbfbfe9d8,0x2,0x0)             ERR#10 'No child processes'
> wait4(0xffffffff,0xbfbfe9d8,0x2,0x0)             ERR#10 'No child processes'
> ......

I've seen this behaviour for makeworld, and just today for making a kernel.
It is hard to reproduce for makeworld.  At first I thought it might have
been caused by a recent commit to the wait loop.  It wasn't exactly that.
Next I thought that it was a kernel bug in my version of exit1().  Moving
things back to nearer where they were seemed to reduce the problem but
didn't fix it.  I'm happy that it is not my bug and can easily be reproduced
:-).

Bruce


More information about the freebsd-bugs mailing list