RJK's general signal-handling robustness patch. Should fix the weird