mirror of
https://github.com/fluencelabs/musl
synced 2025-06-10 05:21:34 +00:00
it should be noted that the "real" __sysv_signal, which we do not implement, is semantically different from signal. references to __sysv_signal arise in code built against glibc under certain combinations of feature test macros, and are almost surely unintentional since the legacy sysv signal behavior has fundamental race conditions that cannot be worked around and which make it impossible to use safely.
17 lines
414 B
C
17 lines
414 B
C
#include <signal.h>
|
|
#include "syscall.h"
|
|
#include "libc.h"
|
|
|
|
int __sigaction(int, const struct sigaction *, struct sigaction *);
|
|
|
|
void (*signal(int sig, void (*func)(int)))(int)
|
|
{
|
|
struct sigaction sa_old, sa = { .sa_handler = func, .sa_flags = SA_RESTART };
|
|
if (__sigaction(sig, &sa, &sa_old) < 0)
|
|
return SIG_ERR;
|
|
return sa_old.sa_handler;
|
|
}
|
|
|
|
weak_alias(signal, bsd_signal);
|
|
weak_alias(signal, __sysv_signal);
|