fix infinite loop when handling syscalls.