Use sigaction() instead of signal()

This allows setting SA_RESTART.