http://www.perlmonks.org?node_id=493124

0xbeef has asked for the wisdom of the Perl Monks concerning the following question:

It have a program that collects output from o/s commands by forking a child process and reading its stdout/stderr seperately via a pipe. The duration and output of each exec() may not exceed a certain threshold, otherwise the exec'd child gets killed and the next system command gets run.

I have code that does this _slowly_ - maybe since I'm not buffering the reads from the pipe, but handling each line of output in terms of measuring size/duration. I cannot think of any other way of enforcing time/size thresholds on the child process... I'm hoping an enlightened monk would have a clever trick for something like this?

Conditions:
1. Child process' stdout and stderr must be processed in seperate handles.
2. exec'd child cannot run for longer than xx secs
3. exec child's stdout and stderr must not exceed x lines/size

0xbeef