xref: /minix3/minix/lib/libc/sys/sigreturn.c (revision 433d6423c39e34ec4b79c950597bb2d236f886be)
1*433d6423SLionel Sambuc #include "namespace.h"
2*433d6423SLionel Sambuc 
3*433d6423SLionel Sambuc #include <sys/cdefs.h>
4*433d6423SLionel Sambuc #include <lib.h>
5*433d6423SLionel Sambuc 
6*433d6423SLionel Sambuc #include <string.h>
7*433d6423SLionel Sambuc #include <assert.h>
8*433d6423SLionel Sambuc #include <signal.h>
9*433d6423SLionel Sambuc #include <string.h>
10*433d6423SLionel Sambuc #include <sys/signal.h>
11*433d6423SLionel Sambuc #include <machine/signal.h>
12*433d6423SLionel Sambuc 
sigreturn(struct sigcontext * scp)13*433d6423SLionel Sambuc int sigreturn(struct sigcontext *scp)
14*433d6423SLionel Sambuc {
15*433d6423SLionel Sambuc   sigset_t set;
16*433d6423SLionel Sambuc 
17*433d6423SLionel Sambuc   /* The message can't be on the stack, because the stack will vanish out
18*433d6423SLionel Sambuc    * from under us.  The send part of ipc_sendrec will succeed, but when
19*433d6423SLionel Sambuc    * a message is sent to restart the current process, who knows what will
20*433d6423SLionel Sambuc    * be in the place formerly occupied by the message?
21*433d6423SLionel Sambuc    */
22*433d6423SLionel Sambuc   static message m;
23*433d6423SLionel Sambuc 
24*433d6423SLionel Sambuc   /* Protect against race conditions by blocking all interrupts. */
25*433d6423SLionel Sambuc   sigfillset(&set);		/* splhi */
26*433d6423SLionel Sambuc   sigprocmask(SIG_SETMASK, &set, NULL);
27*433d6423SLionel Sambuc 
28*433d6423SLionel Sambuc   memset(&m, 0, sizeof(m));
29*433d6423SLionel Sambuc   m.m_lc_pm_sigset.set = scp->sc_mask;
30*433d6423SLionel Sambuc   m.m_lc_pm_sigset.ctx = (vir_bytes)scp;
31*433d6423SLionel Sambuc   return(_syscall(PM_PROC_NR, PM_SIGRETURN, &m)); /* normally doesn't return */
32*433d6423SLionel Sambuc }
33