moved signal handler installation sooner in main()