Fixed possible hang on startup issue

The signal handlers to ignore terminal signals need to be called before
we set our pgid and call tcsetpgrp, otherwise tcsetpgrp could send us a TTIN
signal since we are no longer the fg pgid when we change our pgid.