Hi, everybody, thank you for your attention on this problem. Finally I got the root cause. The reason is that the Linux kernel is configure to use console as standard output. And at the time when the perl is running the serial port is stuck. So the perl script hangs.
in reply to Re^3: print() function hang for long time
in thread print() function hang for long time