setup signal handler first to avoid race condition
more reasonable