add fcntl(FD_DUP)
fix some issue that might cause memory leak