fix the bug that causes bad file discriptor, but output many info
for debug