options/ansi: Return SIG_ERR instead of panic when sys_sigaction fails in signal()
This is in line with the POSIX spec.
Programs such as zsh may pass an invalid signal number and crash on EINVAL.
@@ -17,8 +17,10 @@ __sighandler signal(int sn, __sighandler handler) {
sa.sa_flags = 0;
sa.sa_mask = 0;
struct sigaction old;
- if(mlibc::sys_sigaction(sn, &sa, &old))
- mlibc::panicLogger() << "\e[31mmlibc: sys_sigaction() failed\e[39m" << frg::endlog;
+ if(int e = mlibc::sys_sigaction(sn, &sa, &old)){
+ errno = e;
+ return SIG_ERR;
+ }
return old.sa_handler;
}
