libc: implement signal(3)

Fixes #4824
This commit is contained in:
Benjamin Lamowski 2023-04-24 11:27:28 +02:00 committed by Christian Helmuth
parent 70644186c1
commit 29238498b6
2 changed files with 13 additions and 1 deletions

View File

@ -129,7 +129,6 @@ DUMMY(int , -1, sched_setparam, (pid_t, const sched_param *))
DUMMY(int , -1, sched_setscheduler, (pid_t, int, const sched_param *))
DUMMY(int , -1, sched_yield, (void))
DUMMY(int , -1, __semctl, (void))
DUMMY_SILENT(sig_t, SIG_ERR, signal, (int, sig_t));
DUMMY_SILENT(int , -1, sigaltstack, (const stack_t *, stack_t *))
DUMMY(int , -1, setegid, (uid_t))
DUMMY(int , -1, seteuid, (uid_t))

View File

@ -131,6 +131,19 @@ extern "C" int sigaction(int signum, const struct sigaction *act, struct sigacti
}
extern "C" __sighandler_t * signal(int sig, __sighandler_t * func)
{
struct sigaction oact { }, act { };
act.sa_handler = func;
if (sigaction(sig, &act, &oact) == 0)
return oact.sa_handler;
errno = EINVAL;
return SIG_ERR;
}
extern "C" int _sigaction(int, const struct sigaction *, struct sigaction *) __attribute__((weak, alias("sigaction")));
extern "C" int __sys_sigaction(int, const struct sigaction *, struct sigaction *) __attribute__((weak, alias("sigaction")));
extern "C" int __libc_sigaction(int, const struct sigaction *, struct sigaction *) __attribute__((weak, alias("sigaction")));