moved signal handler initialization before thread start