Skip to content

Commit

Permalink
libc: implement signal(3)
Browse files Browse the repository at this point in the history
Fixes #4824
  • Loading branch information
atopia authored and chelmuth committed May 30, 2023
1 parent 7064418 commit 2923849
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
1 change: 0 additions & 1 deletion repos/libports/src/lib/libc/dummies.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
13 changes: 13 additions & 0 deletions repos/libports/src/lib/libc/signal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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")));
Expand Down

0 comments on commit 2923849

Please sign in to comment.