in reply to Using SIG{ALRM} within while loop.

Not that others haven't addressed your stated problem already, but you might consider using an off the shelf event loop like POE or AnyEvent rather than trying to roll your own.

The cake is a lie.
The cake is a lie.
The cake is a lie.