Headless booting should shutdown if signalled, before exiting
Headless booting should shutdown if signalled, before exiting

Summary:
This will prevent races where the termination of the idb process is assumed to mean that the Simulator is shutdown.

In fact, `idb` will exit **causing** the shutdown. This is due to the way headless booting is implemented to teardown the simulator in this case. However, we should ensure that if we are signalled with a signal that allows us to respond, we will shutdown the simulator before exiting.

The caller in the python-side of idb has backoff to a KILL if wedging occurs. But this means that upon TERM -> wait for companion proc to exit -> proc exit, the simulator is in a **known** shutdown state.

This is very helpful when dealing with "cloning" where one may wish to clone a shutdown sim. If the sim is cloned on a "Shutting Down" sim, then it will fail. This will avoid that

Reviewed By: c-ryan747

Differential Revision: D21383002

fbshipit-source-id: 4b70715bb3292eb73b16f675ed054b53c47fb4ee

facebook/FBSimulatorControl,facebook/FBSimulatorControl,facebook/FBSimulatorControl,facebook/FBSimulatorControl,facebook/FBSimulatorControl