Fix signal handlers being inherited by child processes

This fix is similar to
02acdac479ba8ee0fb85682910aa869d284ce3ef.