Modify set_exit_on_term

This implementation is not thread-safe and will cause harmful exit,
but at least it will not cause deadlock on exit.
Remove unnecessary errno

sigwait doesn't set errno
Remove calling sigprocmask in thread generated in set_exit_on_term

In pthread, child thread's signal mask inherits parent thread's one.