Factor out tty signal ignoring and setsid() and such into its own function.