Magellan Linux

Contents of /trunk/mkinitrd-magellan/klibc/usr/klibc/sigaction.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 532 - (show annotations) (download)
Sat Sep 1 22:45:15 2007 UTC (16 years, 8 months ago) by niro
File MIME type: text/plain
File size: 1321 byte(s)
-import if magellan mkinitrd; it is a fork of redhats mkinitrd-5.0.8 with all magellan patches and features; deprecates magellan-src/mkinitrd

1 /*
2 * sigaction.c
3 */
4
5 #include <signal.h>
6 #include <sys/syscall.h>
7 #include <klibc/sysconfig.h>
8
9 __extern void __sigreturn(void);
10 __extern int __sigaction(int, const struct sigaction *, struct sigaction *);
11 #ifdef __sparc__
12 __extern int __rt_sigaction(int, const struct sigaction *, struct sigaction *,
13 void (*)(void), size_t);
14 #else
15 __extern int __rt_sigaction(int, const struct sigaction *, struct sigaction *,
16 size_t);
17 #endif
18
19 int sigaction(int sig, const struct sigaction *act, struct sigaction *oact)
20 {
21 int rv;
22
23 #if _KLIBC_NEEDS_SA_RESTORER
24 struct sigaction sa;
25
26 if (act && !(act->sa_flags & SA_RESTORER)) {
27 sa = *act;
28 act = &sa;
29
30 /* The kernel can't be trusted to have a valid default
31 restorer */
32 sa.sa_flags |= SA_RESTORER;
33 sa.sa_restorer = &__sigreturn;
34 }
35 #endif
36
37 #if _KLIBC_USE_RT_SIG
38 # ifdef __sparc__
39 {
40 void (*restorer)(void);
41 restorer = (act && act->sa_flags & SA_RESTORER)
42 ? (void (*)(void))((uintptr_t)act->sa_restorer - 8)
43 : NULL;
44 rv = __rt_sigaction(sig, act, oact, restorer, sizeof(sigset_t));
45 }
46 # else
47 rv = __rt_sigaction(sig, act, oact, sizeof(sigset_t));
48 # endif
49 #else
50 rv = __sigaction(sig, act, oact);
51 #endif
52
53 #if _KLIBC_NEEDS_SA_RESTORER
54 if (oact && (oact->sa_restorer == &__sigreturn)) {
55 oact->sa_flags &= ~SA_RESTORER;
56 }
57 #endif
58
59 return rv;
60 }