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