in reply to enforce timeout in loop

I think we need to know what kind of processing you're really doing on those array elements. Are you timing out a socket or some other IO handle or a child process? The timeout mechanism will differ for each. Socket flags, alarm, four-arg select, or kill/signal handling may be called for, but which depends on what you're doing.

After Compline,
Zaxo