Register signal handler before tty setup