This may or may not solve your issue, It is recommended to use sigaction() instead of signal(). sigaction() is more consistent and reliable, allowing better control over signal delivery and handling. Generally, from experience, sigaction is a lot more portable, as concured by the GNU Docs.