preventing leak of file descriptors