modify signal handling.

Modify signal handling from asynchronous signal handler to synchronous signal handling thread.

To respect async-signal-safe.

Can you split this into 3 test cases if you don't need to check some state transition?