modify signal handling.

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