This source file includes following definitions.
- openbsd_to_freebsd_sigaction
- freebsd_to_openbsd_sigaction
- freebsd_sys_sigaction40
- freebsd_sys_sigpending40
- freebsd_sys_sigprocmask40
- freebsd_sys_sigsuspend40
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41 #include <sys/param.h>
42 #include <sys/proc.h>
43 #include <sys/signalvar.h>
44 #include <sys/signal.h>
45 #include <sys/systm.h>
46 #include <sys/mount.h>
47
48 #include <compat/freebsd/freebsd_signal.h>
49 #include <compat/freebsd/freebsd_syscallargs.h>
50
51 static void freebsd_to_openbsd_sigaction(struct freebsd_sigaction *,
52 struct sigaction *);
53
54 static void openbsd_to_freebsd_sigaction(struct sigaction *,
55 struct freebsd_sigaction *);
56
57 static void
58 openbsd_to_freebsd_sigaction(obsa, fbsa)
59 struct sigaction *obsa;
60 struct freebsd_sigaction *fbsa;
61 {
62 bzero(fbsa, sizeof(struct freebsd_sigaction));
63 fbsa->freebsd_sa_handler = obsa->sa_handler;
64 bcopy(&obsa->sa_mask, &fbsa->freebsd_sa_mask.__bits[0],
65 sizeof(sigset_t));
66 fbsa->freebsd_sa_flags = obsa->sa_flags;
67 }
68
69 static void
70 freebsd_to_openbsd_sigaction(fbsa, obsa)
71 struct freebsd_sigaction *fbsa;
72 struct sigaction *obsa;
73 {
74 obsa->sa_handler = fbsa->freebsd_sa_handler;
75 bcopy(&fbsa->freebsd_sa_mask.__bits[0], &obsa->sa_mask,
76 sizeof(sigset_t));
77 obsa->sa_flags = fbsa->freebsd_sa_flags;
78 }
79
80
81 int
82 freebsd_sys_sigaction40(p, v, retval)
83 struct proc *p;
84 void *v;
85 register_t *retval;
86 {
87 register struct freebsd_sys_sigaction40_args
88
89
90
91 *uap = v;
92 struct sigaction vec;
93 register struct sigaction *sa;
94 struct freebsd_sigaction fbsa;
95 register struct sigacts *ps = p->p_sigacts;
96 register int signum;
97 int bit, error;
98
99 signum = SCARG(uap, sig);
100 if (signum <= 0 || signum >= NSIG ||
101 (SCARG(uap, act) && (signum == SIGKILL || signum == SIGSTOP)))
102 return (EINVAL);
103 sa = &vec;
104 if (SCARG(uap, oact)) {
105 sa->sa_handler = ps->ps_sigact[signum];
106 sa->sa_mask = ps->ps_catchmask[signum];
107 bit = sigmask(signum);
108 sa->sa_flags = 0;
109 if ((ps->ps_sigonstack & bit) != 0)
110 sa->sa_flags |= SA_ONSTACK;
111 if ((ps->ps_sigintr & bit) == 0)
112 sa->sa_flags |= SA_RESTART;
113 if ((ps->ps_sigreset & bit) != 0)
114 sa->sa_flags |= SA_RESETHAND;
115 if ((ps->ps_siginfo & bit) != 0)
116 sa->sa_flags |= SA_SIGINFO;
117 if (signum == SIGCHLD) {
118 if ((p->p_flag & P_NOCLDSTOP) != 0)
119 sa->sa_flags |= SA_NOCLDSTOP;
120 if ((p->p_flag & P_NOCLDWAIT) != 0)
121 sa->sa_flags |= SA_NOCLDWAIT;
122 }
123 if ((sa->sa_mask & bit) == 0)
124 sa->sa_flags |= SA_NODEFER;
125 sa->sa_mask &= ~bit;
126 openbsd_to_freebsd_sigaction(sa, &fbsa);
127 error = copyout((caddr_t)&fbsa, (caddr_t)SCARG(uap, oact),
128 sizeof (struct freebsd_sigaction));
129 if (error)
130 return (error);
131 }
132 if (SCARG(uap, act)) {
133 error = copyin((caddr_t)SCARG(uap, act), (caddr_t)&fbsa,
134 sizeof (struct freebsd_sigaction));
135 if (error)
136 return (error);
137 freebsd_to_openbsd_sigaction(&fbsa, sa);
138 setsigvec(p, signum, sa);
139 }
140 return (0);
141 }
142
143
144 int
145 freebsd_sys_sigpending40(p, v, retval)
146 struct proc *p;
147 void *v;
148 register_t *retval;
149 {
150 register struct freebsd_sys_sigpending40_args
151
152 *uap = v;
153 freebsd_sigset_t fss;
154
155 bcopy(&p->p_siglist, &fss.__bits[0], sizeof(sigset_t));
156 return (copyout((caddr_t)&fss, (caddr_t)SCARG(uap, set), sizeof(fss)));
157 }
158
159 int
160 freebsd_sys_sigprocmask40(p, v, retval)
161 register struct proc *p;
162 void *v;
163 register_t *retval;
164 {
165 struct freebsd_sys_sigprocmask40_args
166
167
168
169 *uap = v;
170 freebsd_sigset_t nss, oss;
171 sigset_t obnss;
172 int error = 0;
173
174 if (SCARG(uap, set)) {
175 error = copyin(SCARG(uap, set), &nss, sizeof(nss));
176 if (error)
177 return (error);
178 }
179 if (SCARG(uap, oset)) {
180 bzero(&oss, sizeof(freebsd_sigset_t));
181 bcopy(&p->p_sigmask, &oss.__bits[0], sizeof(sigset_t));
182 error = copyout((caddr_t)&oss, (caddr_t)SCARG(uap, oset),
183 sizeof(freebsd_sigset_t));
184 if (error)
185 return (error);
186 }
187 if (SCARG(uap, set)) {
188 bcopy(&nss.__bits[0], &obnss, sizeof(sigset_t));
189 (void)splhigh();
190 switch (SCARG(uap, how)) {
191 case SIG_BLOCK:
192 p->p_sigmask |= obnss &~ sigcantmask;
193 break;
194 case SIG_UNBLOCK:
195 p->p_sigmask &= ~obnss;
196 break;
197 case SIG_SETMASK:
198 p->p_sigmask = obnss &~ sigcantmask;
199 break;
200 default:
201 error = EINVAL;
202 break;
203 }
204 (void) spl0();
205 }
206 return (error);
207 }
208
209 int
210 freebsd_sys_sigsuspend40(p, v, retval)
211 register struct proc *p;
212 void *v;
213 register_t *retval;
214 {
215 struct freebsd_sys_sigsuspend40_args
216
217 *uap = v;
218 register struct sigacts *ps = p->p_sigacts;
219 freebsd_sigset_t fbset;
220 sigset_t obset;
221
222 copyin(SCARG(uap, sigmask), &fbset, sizeof(freebsd_sigset_t));
223 bcopy(&fbset.__bits[0], &obset, sizeof(sigset_t));
224
225
226
227
228
229
230
231 ps->ps_oldmask = p->p_sigmask;
232 ps->ps_flags |= SAS_OLDMASK;
233 p->p_sigmask = obset &~ sigcantmask;
234 while (tsleep((caddr_t) ps, PPAUSE|PCATCH, "pause", 0) == 0)
235 ;
236
237 return (EINTR);
238 }