Incidentally, might I suggest something to the effect of: #!/bin/rc fn cleanup { for(i in $apids) { echo kill >/proc/$i/note } } fn sigint { cleanup } fn sigterm { cleanup } apids=() for(f) { tail -f $f | sed 's/^/'$f:/ & apids = ($apids $apid) } wait