Statistics
| Branch: | Revision:

root / darwin-user / signal.c @ 4870852c

History | View | Annotate | Download (12.2 kB)

1 831b7825 ths
/*
2 831b7825 ths
 *  Emulation of Linux signals
3 831b7825 ths
 *
4 831b7825 ths
 *  Copyright (c) 2003 Fabrice Bellard
5 831b7825 ths
 *
6 831b7825 ths
 *  This program is free software; you can redistribute it and/or modify
7 831b7825 ths
 *  it under the terms of the GNU General Public License as published by
8 831b7825 ths
 *  the Free Software Foundation; either version 2 of the License, or
9 831b7825 ths
 *  (at your option) any later version.
10 831b7825 ths
 *
11 831b7825 ths
 *  This program is distributed in the hope that it will be useful,
12 831b7825 ths
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 831b7825 ths
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 831b7825 ths
 *  GNU General Public License for more details.
15 831b7825 ths
 *
16 831b7825 ths
 *  You should have received a copy of the GNU General Public License
17 831b7825 ths
 *  along with this program; if not, write to the Free Software
18 530e7615 blueswir1
 *  Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
19 530e7615 blueswir1
 *  MA 02110-1301, USA.
20 831b7825 ths
 */
21 831b7825 ths
#include <stdlib.h>
22 831b7825 ths
#include <stdio.h>
23 831b7825 ths
#include <string.h>
24 831b7825 ths
#include <stdarg.h>
25 831b7825 ths
#include <unistd.h>
26 831b7825 ths
#include <signal.h>
27 831b7825 ths
#include <errno.h>
28 831b7825 ths
#include <sys/ucontext.h>
29 831b7825 ths
30 831b7825 ths
#ifdef __ia64__
31 831b7825 ths
#undef uc_mcontext
32 831b7825 ths
#undef uc_sigmask
33 831b7825 ths
#undef uc_stack
34 831b7825 ths
#undef uc_link
35 831b7825 ths
#endif
36 831b7825 ths
37 831b7825 ths
#include <signal.h>
38 831b7825 ths
39 831b7825 ths
#include "qemu.h"
40 7d99a001 blueswir1
#include "qemu-common.h"
41 831b7825 ths
42 831b7825 ths
#define DEBUG_SIGNAL
43 831b7825 ths
44 831b7825 ths
#define MAX_SIGQUEUE_SIZE 1024
45 831b7825 ths
46 831b7825 ths
struct sigqueue {
47 831b7825 ths
    struct sigqueue *next;
48 831b7825 ths
    target_siginfo_t info;
49 831b7825 ths
};
50 831b7825 ths
51 831b7825 ths
struct emulated_sigaction {
52 831b7825 ths
    struct target_sigaction sa;
53 831b7825 ths
    int pending; /* true if signal is pending */
54 831b7825 ths
    struct sigqueue *first;
55 831b7825 ths
    struct sigqueue info; /* in order to always have memory for the
56 831b7825 ths
                             first signal, we put it here */
57 831b7825 ths
};
58 831b7825 ths
59 249c4c32 blueswir1
static struct sigaltstack target_sigaltstack_used = {
60 831b7825 ths
    0, 0, SA_DISABLE
61 831b7825 ths
};
62 831b7825 ths
63 831b7825 ths
static struct emulated_sigaction sigact_table[NSIG];
64 831b7825 ths
static struct sigqueue sigqueue_table[MAX_SIGQUEUE_SIZE]; /* siginfo queue */
65 831b7825 ths
static struct sigqueue *first_free; /* first free siginfo queue entry */
66 831b7825 ths
static int signal_pending; /* non zero if a signal may be pending */
67 831b7825 ths
68 831b7825 ths
static void host_signal_handler(int host_signum, siginfo_t *info,
69 831b7825 ths
                                void *puc);
70 831b7825 ths
71 831b7825 ths
72 831b7825 ths
static inline int host_to_target_signal(int sig)
73 831b7825 ths
{
74 831b7825 ths
    return sig;
75 831b7825 ths
}
76 831b7825 ths
77 831b7825 ths
static inline int target_to_host_signal(int sig)
78 831b7825 ths
{
79 831b7825 ths
    return sig;
80 831b7825 ths
}
81 831b7825 ths
82 831b7825 ths
/* siginfo conversion */
83 831b7825 ths
84 831b7825 ths
85 831b7825 ths
86 831b7825 ths
void host_to_target_siginfo(target_siginfo_t *tinfo, const siginfo_t *info)
87 831b7825 ths
{
88 831b7825 ths
89 831b7825 ths
}
90 831b7825 ths
91 831b7825 ths
void target_to_host_siginfo(siginfo_t *info, const target_siginfo_t *tinfo)
92 831b7825 ths
{
93 831b7825 ths
94 831b7825 ths
}
95 831b7825 ths
96 831b7825 ths
void signal_init(void)
97 831b7825 ths
{
98 831b7825 ths
    struct sigaction act;
99 831b7825 ths
    int i;
100 831b7825 ths
101 831b7825 ths
    /* set all host signal handlers. ALL signals are blocked during
102 831b7825 ths
       the handlers to serialize them. */
103 831b7825 ths
    sigfillset(&act.sa_mask);
104 831b7825 ths
    act.sa_flags = SA_SIGINFO;
105 831b7825 ths
    act.sa_sigaction = host_signal_handler;
106 831b7825 ths
    for(i = 1; i < NSIG; i++) {
107 831b7825 ths
        sigaction(i, &act, NULL);
108 831b7825 ths
    }
109 831b7825 ths
110 831b7825 ths
    memset(sigact_table, 0, sizeof(sigact_table));
111 831b7825 ths
112 831b7825 ths
    first_free = &sigqueue_table[0];
113 831b7825 ths
    for(i = 0; i < MAX_SIGQUEUE_SIZE - 1; i++)
114 831b7825 ths
        sigqueue_table[i].next = &sigqueue_table[i + 1];
115 831b7825 ths
    sigqueue_table[MAX_SIGQUEUE_SIZE - 1].next = NULL;
116 831b7825 ths
}
117 831b7825 ths
118 831b7825 ths
/* signal queue handling */
119 831b7825 ths
120 831b7825 ths
static inline struct sigqueue *alloc_sigqueue(void)
121 831b7825 ths
{
122 831b7825 ths
    struct sigqueue *q = first_free;
123 831b7825 ths
    if (!q)
124 831b7825 ths
        return NULL;
125 831b7825 ths
    first_free = q->next;
126 831b7825 ths
    return q;
127 831b7825 ths
}
128 831b7825 ths
129 831b7825 ths
static inline void free_sigqueue(struct sigqueue *q)
130 831b7825 ths
{
131 831b7825 ths
    q->next = first_free;
132 831b7825 ths
    first_free = q;
133 831b7825 ths
}
134 831b7825 ths
135 831b7825 ths
/* abort execution with signal */
136 a5e50b26 malc
void QEMU_NORETURN force_sig(int sig)
137 831b7825 ths
{
138 831b7825 ths
    int host_sig;
139 831b7825 ths
    host_sig = target_to_host_signal(sig);
140 831b7825 ths
    fprintf(stderr, "qemu: uncaught target signal %d (%s) - exiting\n",
141 831b7825 ths
            sig, strsignal(host_sig));
142 831b7825 ths
    _exit(-host_sig);
143 831b7825 ths
}
144 831b7825 ths
145 831b7825 ths
/* queue a signal so that it will be send to the virtual CPU as soon
146 831b7825 ths
   as possible */
147 831b7825 ths
int queue_signal(int sig, target_siginfo_t *info)
148 831b7825 ths
{
149 831b7825 ths
    struct emulated_sigaction *k;
150 831b7825 ths
    struct sigqueue *q, **pq;
151 831b7825 ths
    target_ulong handler;
152 831b7825 ths
153 831b7825 ths
#if defined(DEBUG_SIGNAL)
154 831b7825 ths
    fprintf(stderr, "queue_signal: sig=%d\n",
155 831b7825 ths
            sig);
156 831b7825 ths
#endif
157 831b7825 ths
    k = &sigact_table[sig - 1];
158 831b7825 ths
    handler = (target_ulong)k->sa.sa_handler;
159 831b7825 ths
    if (handler == SIG_DFL) {
160 831b7825 ths
        /* default handler : ignore some signal. The other are fatal */
161 831b7825 ths
        if (sig != SIGCHLD &&
162 831b7825 ths
            sig != SIGURG &&
163 831b7825 ths
            sig != SIGWINCH) {
164 831b7825 ths
            force_sig(sig);
165 831b7825 ths
        } else {
166 831b7825 ths
            return 0; /* indicate ignored */
167 831b7825 ths
        }
168 831b7825 ths
    } else if (handler == host_to_target_signal(SIG_IGN)) {
169 831b7825 ths
        /* ignore signal */
170 831b7825 ths
        return 0;
171 831b7825 ths
    } else if (handler == host_to_target_signal(SIG_ERR)) {
172 831b7825 ths
        force_sig(sig);
173 831b7825 ths
    } else {
174 831b7825 ths
        pq = &k->first;
175 831b7825 ths
        if (!k->pending) {
176 831b7825 ths
            /* first signal */
177 831b7825 ths
            q = &k->info;
178 831b7825 ths
        } else {
179 831b7825 ths
            q = alloc_sigqueue();
180 831b7825 ths
            if (!q)
181 831b7825 ths
                return -EAGAIN;
182 831b7825 ths
            while (*pq != NULL)
183 831b7825 ths
                pq = &(*pq)->next;
184 831b7825 ths
        }
185 831b7825 ths
        *pq = q;
186 831b7825 ths
        q->info = *info;
187 831b7825 ths
        q->next = NULL;
188 831b7825 ths
        k->pending = 1;
189 831b7825 ths
        /* signal that a new signal is pending */
190 831b7825 ths
        signal_pending = 1;
191 831b7825 ths
        return 1; /* indicates that the signal was queued */
192 831b7825 ths
    }
193 831b7825 ths
}
194 831b7825 ths
195 831b7825 ths
static void host_signal_handler(int host_signum, siginfo_t *info,
196 831b7825 ths
                                void *puc)
197 831b7825 ths
{
198 831b7825 ths
    int sig;
199 831b7825 ths
    target_siginfo_t tinfo;
200 831b7825 ths
201 831b7825 ths
    /* the CPU emulator uses some host signals to detect exceptions,
202 831b7825 ths
       we we forward to it some signals */
203 ec6338ba bellard
    if (host_signum == SIGSEGV || host_signum == SIGBUS) {
204 831b7825 ths
        if (cpu_signal_handler(host_signum, (void*)info, puc))
205 831b7825 ths
            return;
206 831b7825 ths
    }
207 831b7825 ths
208 831b7825 ths
    /* get target signal number */
209 831b7825 ths
    sig = host_to_target_signal(host_signum);
210 831b7825 ths
    if (sig < 1 || sig > NSIG)
211 831b7825 ths
        return;
212 831b7825 ths
213 831b7825 ths
#if defined(DEBUG_SIGNAL)
214 831b7825 ths
        fprintf(stderr, "qemu: got signal %d\n", sig);
215 831b7825 ths
#endif
216 831b7825 ths
    if (queue_signal(sig, &tinfo) == 1) {
217 831b7825 ths
        /* interrupt the virtual CPU as soon as possible */
218 3098dba0 aurel32
        cpu_exit(global_env);
219 831b7825 ths
    }
220 831b7825 ths
}
221 831b7825 ths
222 831b7825 ths
int do_sigaltstack(const struct sigaltstack *ss, struct sigaltstack *oss)
223 831b7825 ths
{
224 831b7825 ths
    /* XXX: test errors */
225 831b7825 ths
    if(oss)
226 831b7825 ths
    {
227 831b7825 ths
        oss->ss_sp = tswap32(target_sigaltstack_used.ss_sp);
228 831b7825 ths
        oss->ss_size = tswap32(target_sigaltstack_used.ss_size);
229 831b7825 ths
        oss->ss_flags = tswap32(target_sigaltstack_used.ss_flags);
230 831b7825 ths
    }
231 831b7825 ths
    if(ss)
232 831b7825 ths
    {
233 831b7825 ths
        target_sigaltstack_used.ss_sp = tswap32(ss->ss_sp);
234 831b7825 ths
        target_sigaltstack_used.ss_size = tswap32(ss->ss_size);
235 831b7825 ths
        target_sigaltstack_used.ss_flags = tswap32(ss->ss_flags);
236 831b7825 ths
    }
237 831b7825 ths
    return 0;
238 831b7825 ths
}
239 831b7825 ths
240 831b7825 ths
int do_sigaction(int sig, const struct sigaction *act,
241 831b7825 ths
                 struct sigaction *oact)
242 831b7825 ths
{
243 831b7825 ths
    struct emulated_sigaction *k;
244 831b7825 ths
    struct sigaction act1;
245 831b7825 ths
    int host_sig;
246 831b7825 ths
247 831b7825 ths
    if (sig < 1 || sig > NSIG)
248 831b7825 ths
        return -EINVAL;
249 831b7825 ths
250 831b7825 ths
    k = &sigact_table[sig - 1];
251 831b7825 ths
#if defined(DEBUG_SIGNAL)
252 831b7825 ths
    fprintf(stderr, "sigaction 1 sig=%d act=0x%08x, oact=0x%08x\n",
253 831b7825 ths
            sig, (int)act, (int)oact);
254 831b7825 ths
#endif
255 831b7825 ths
    if (oact) {
256 831b7825 ths
#if defined(DEBUG_SIGNAL)
257 831b7825 ths
    fprintf(stderr, "sigaction 1 sig=%d act=0x%08x, oact=0x%08x\n",
258 831b7825 ths
            sig, (int)act, (int)oact);
259 831b7825 ths
#endif
260 831b7825 ths
261 831b7825 ths
        oact->sa_handler = tswapl(k->sa.sa_handler);
262 831b7825 ths
        oact->sa_flags = tswapl(k->sa.sa_flags);
263 831b7825 ths
        oact->sa_mask = tswapl(k->sa.sa_mask);
264 831b7825 ths
    }
265 831b7825 ths
    if (act) {
266 831b7825 ths
#if defined(DEBUG_SIGNAL)
267 831b7825 ths
    fprintf(stderr, "sigaction handler 0x%x flag 0x%x mask 0x%x\n",
268 831b7825 ths
            act->sa_handler, act->sa_flags, act->sa_mask);
269 831b7825 ths
#endif
270 831b7825 ths
271 831b7825 ths
        k->sa.sa_handler = tswapl(act->sa_handler);
272 831b7825 ths
        k->sa.sa_flags = tswapl(act->sa_flags);
273 831b7825 ths
        k->sa.sa_mask = tswapl(act->sa_mask);
274 831b7825 ths
        /* we update the host signal state */
275 831b7825 ths
        host_sig = target_to_host_signal(sig);
276 831b7825 ths
        if (host_sig != SIGSEGV && host_sig != SIGBUS) {
277 831b7825 ths
#if defined(DEBUG_SIGNAL)
278 831b7825 ths
    fprintf(stderr, "sigaction handler going to call sigaction\n",
279 831b7825 ths
            act->sa_handler, act->sa_flags, act->sa_mask);
280 831b7825 ths
#endif
281 831b7825 ths
282 831b7825 ths
            sigfillset(&act1.sa_mask);
283 831b7825 ths
            act1.sa_flags = SA_SIGINFO;
284 831b7825 ths
            if (k->sa.sa_flags & SA_RESTART)
285 831b7825 ths
                act1.sa_flags |= SA_RESTART;
286 831b7825 ths
            /* NOTE: it is important to update the host kernel signal
287 831b7825 ths
               ignore state to avoid getting unexpected interrupted
288 831b7825 ths
               syscalls */
289 831b7825 ths
            if (k->sa.sa_handler == SIG_IGN) {
290 831b7825 ths
                act1.sa_sigaction = (void *)SIG_IGN;
291 831b7825 ths
            } else if (k->sa.sa_handler == SIG_DFL) {
292 831b7825 ths
                act1.sa_sigaction = (void *)SIG_DFL;
293 831b7825 ths
            } else {
294 831b7825 ths
                act1.sa_sigaction = host_signal_handler;
295 831b7825 ths
            }
296 831b7825 ths
            sigaction(host_sig, &act1, NULL);
297 831b7825 ths
        }
298 831b7825 ths
    }
299 831b7825 ths
    return 0;
300 831b7825 ths
}
301 831b7825 ths
302 831b7825 ths
303 831b7825 ths
#ifdef TARGET_I386
304 831b7825 ths
305 831b7825 ths
static inline void *
306 831b7825 ths
get_sigframe(struct emulated_sigaction *ka, CPUX86State *env, size_t frame_size)
307 831b7825 ths
{
308 831b7825 ths
    /* XXX Fix that */
309 831b7825 ths
    if(target_sigaltstack_used.ss_flags & SA_DISABLE)
310 831b7825 ths
    {
311 831b7825 ths
        int esp;
312 831b7825 ths
        /* Default to using normal stack */
313 831b7825 ths
        esp = env->regs[R_ESP];
314 831b7825 ths
315 831b7825 ths
        return (void *)((esp - frame_size) & -8ul);
316 831b7825 ths
    }
317 831b7825 ths
    else
318 831b7825 ths
    {
319 831b7825 ths
        return target_sigaltstack_used.ss_sp;
320 831b7825 ths
    }
321 831b7825 ths
}
322 831b7825 ths
323 831b7825 ths
static void setup_frame(int sig, struct emulated_sigaction *ka,
324 831b7825 ths
                        void *set, CPUState *env)
325 831b7825 ths
{
326 831b7825 ths
        void *frame;
327 831b7825 ths
        int i, err = 0;
328 831b7825 ths
329 831b7825 ths
    fprintf(stderr, "setup_frame %d\n", sig);
330 831b7825 ths
        frame = get_sigframe(ka, env, sizeof(*frame));
331 831b7825 ths
332 831b7825 ths
        /* Set up registers for signal handler */
333 831b7825 ths
        env->regs[R_ESP] = (unsigned long) frame;
334 831b7825 ths
        env->eip = (unsigned long) ka->sa.sa_handler;
335 831b7825 ths
336 831b7825 ths
        env->eflags &= ~TF_MASK;
337 831b7825 ths
338 831b7825 ths
        return;
339 831b7825 ths
340 831b7825 ths
give_sigsegv:
341 831b7825 ths
        if (sig == SIGSEGV)
342 831b7825 ths
                ka->sa.sa_handler = SIG_DFL;
343 831b7825 ths
        force_sig(SIGSEGV /* , current */);
344 831b7825 ths
}
345 831b7825 ths
346 831b7825 ths
long do_sigreturn(CPUState *env, int num)
347 831b7825 ths
{
348 831b7825 ths
    int i = 0;
349 831b7825 ths
    struct target_sigcontext *scp = get_int_arg(&i, env);
350 831b7825 ths
    /* XXX Get current signal number */
351 831b7825 ths
    /* XXX Adjust accordin to sc_onstack, sc_mask */
352 831b7825 ths
    if(tswapl(scp->sc_onstack) & 0x1)
353 831b7825 ths
        target_sigaltstack_used.ss_flags |= ~SA_DISABLE;
354 831b7825 ths
    else
355 831b7825 ths
        target_sigaltstack_used.ss_flags &=  SA_DISABLE;
356 831b7825 ths
    int set = tswapl(scp->sc_eax);
357 831b7825 ths
    sigprocmask(SIG_SETMASK, &set, NULL);
358 831b7825 ths
359 831b7825 ths
    fprintf(stderr, "do_sigreturn: partially implemented %x EAX:%x EBX:%x\n", scp->sc_mask, tswapl(scp->sc_eax), tswapl(scp->sc_ebx));
360 831b7825 ths
    fprintf(stderr, "ECX:%x EDX:%x EDI:%x\n", scp->sc_ecx, tswapl(scp->sc_edx), tswapl(scp->sc_edi));
361 831b7825 ths
    fprintf(stderr, "EIP:%x\n", tswapl(scp->sc_eip));
362 831b7825 ths
363 831b7825 ths
    env->regs[R_EAX] = tswapl(scp->sc_eax);
364 831b7825 ths
    env->regs[R_EBX] = tswapl(scp->sc_ebx);
365 831b7825 ths
    env->regs[R_ECX] = tswapl(scp->sc_ecx);
366 831b7825 ths
    env->regs[R_EDX] = tswapl(scp->sc_edx);
367 831b7825 ths
    env->regs[R_EDI] = tswapl(scp->sc_edi);
368 831b7825 ths
    env->regs[R_ESI] = tswapl(scp->sc_esi);
369 831b7825 ths
    env->regs[R_EBP] = tswapl(scp->sc_ebp);
370 831b7825 ths
    env->regs[R_ESP] = tswapl(scp->sc_esp);
371 831b7825 ths
    env->segs[R_SS].selector = (void*)tswapl(scp->sc_ss);
372 831b7825 ths
    env->eflags = tswapl(scp->sc_eflags);
373 831b7825 ths
    env->eip = tswapl(scp->sc_eip);
374 831b7825 ths
    env->segs[R_CS].selector = (void*)tswapl(scp->sc_cs);
375 831b7825 ths
    env->segs[R_DS].selector = (void*)tswapl(scp->sc_ds);
376 831b7825 ths
    env->segs[R_ES].selector = (void*)tswapl(scp->sc_es);
377 831b7825 ths
    env->segs[R_FS].selector = (void*)tswapl(scp->sc_fs);
378 831b7825 ths
    env->segs[R_GS].selector = (void*)tswapl(scp->sc_gs);
379 831b7825 ths
380 831b7825 ths
    /* Again, because our caller's caller will reset EAX */
381 831b7825 ths
    return env->regs[R_EAX];
382 831b7825 ths
}
383 831b7825 ths
384 831b7825 ths
#else
385 831b7825 ths
386 831b7825 ths
static void setup_frame(int sig, struct emulated_sigaction *ka,
387 831b7825 ths
                        void *set, CPUState *env)
388 831b7825 ths
{
389 831b7825 ths
    fprintf(stderr, "setup_frame: not implemented\n");
390 831b7825 ths
}
391 831b7825 ths
392 831b7825 ths
long do_sigreturn(CPUState *env, int num)
393 831b7825 ths
{
394 831b7825 ths
    int i = 0;
395 831b7825 ths
    struct target_sigcontext *scp = get_int_arg(&i, env);
396 831b7825 ths
    fprintf(stderr, "do_sigreturn: not implemented\n");
397 831b7825 ths
    return -ENOSYS;
398 831b7825 ths
}
399 831b7825 ths
400 831b7825 ths
#endif
401 831b7825 ths
402 831b7825 ths
void process_pending_signals(void *cpu_env)
403 831b7825 ths
{
404 831b7825 ths
    struct emulated_sigaction *k;
405 831b7825 ths
    struct sigqueue *q;
406 831b7825 ths
    target_ulong handler;
407 831b7825 ths
    int sig;
408 831b7825 ths
409 831b7825 ths
    if (!signal_pending)
410 831b7825 ths
        return;
411 831b7825 ths
412 831b7825 ths
    k = sigact_table;
413 831b7825 ths
414 831b7825 ths
    for(sig = 1; sig <= NSIG; sig++) {
415 831b7825 ths
        if (k->pending)
416 831b7825 ths
            goto handle_signal;
417 831b7825 ths
        k++;
418 831b7825 ths
    }
419 831b7825 ths
420 831b7825 ths
    /* if no signal is pending, just return */
421 831b7825 ths
    signal_pending = 0;
422 831b7825 ths
    return;
423 831b7825 ths
handle_signal:
424 831b7825 ths
    #ifdef DEBUG_SIGNAL
425 831b7825 ths
    fprintf(stderr, "qemu: process signal %d\n", sig);
426 831b7825 ths
    #endif
427 831b7825 ths
    /* dequeue signal */
428 831b7825 ths
    q = k->first;
429 831b7825 ths
    k->first = q->next;
430 831b7825 ths
    if (!k->first)
431 831b7825 ths
        k->pending = 0;
432 831b7825 ths
433 831b7825 ths
    sig = gdb_handlesig (cpu_env, sig);
434 831b7825 ths
    if (!sig) {
435 831b7825 ths
        fprintf (stderr, "Lost signal\n");
436 831b7825 ths
        abort();
437 831b7825 ths
    }
438 831b7825 ths
439 831b7825 ths
    handler = k->sa.sa_handler;
440 831b7825 ths
    if (handler == SIG_DFL) {
441 831b7825 ths
        /* default handler : ignore some signal. The other are fatal */
442 831b7825 ths
        if (sig != SIGCHLD &&
443 831b7825 ths
            sig != SIGURG &&
444 831b7825 ths
            sig != SIGWINCH) {
445 831b7825 ths
            force_sig(sig);
446 831b7825 ths
        }
447 831b7825 ths
    } else if (handler == SIG_IGN) {
448 831b7825 ths
        /* ignore sig */
449 831b7825 ths
    } else if (handler == SIG_ERR) {
450 831b7825 ths
        force_sig(sig);
451 831b7825 ths
    } else {
452 831b7825 ths
453 831b7825 ths
        setup_frame(sig, k, 0, cpu_env);
454 831b7825 ths
        if (k->sa.sa_flags & SA_RESETHAND)
455 831b7825 ths
            k->sa.sa_handler = SIG_DFL;
456 831b7825 ths
    }
457 831b7825 ths
    if (q != &k->info)
458 831b7825 ths
        free_sigqueue(q);
459 831b7825 ths
}