There are a couple of PM threads about this. I would suggest
reading the updated section of
Re: How to force a timeout on a system call? and also look
bluto's pointer to another thread at
Re: How to force a timeout on a system call? that discuss
the use of open to get the pid of the child and also shows as a possiblity the "stopafter" tool suggested by
Dominus.