fix "too many open files" problem