Removes two races that happen if asynchronous signals are delivered during detach, and the app's signal handler is restored before the safe_read_tls_magic's SIGSEGV is delivered.
There are still possible detach related races left, if asynchronous process-directed signals are delivered after detach is done, or the app has already started a re-attach.
Issue: #3535 (closed)