Use sigaction/sigprocmask instead of signal/sigblock/sigsetmask.