Trap signals before anything else in setup

Signals need to be trapped before anything else is done that might raise
errors. Otherwise the worker could end up not responding to signals from
the master