blob: 1eddd1329e37f5ba5cb9ef53394eb03cbc01500e (
plain)
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
* and is licensed under the *
* Common Public License, Version 1.0 *
* by AT&T Knowledge Ventures *
* *
* A copy of the License is available at *
* http://www.opensource.org/licenses/cpl1.0.txt *
* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* Glenn Fowler <gsf@research.att.com> *
* David Korn <dgk@research.att.com> *
* Phong Vo <kpv@research.att.com> *
* *
***********************************************************************/
#pragma prototyped
/*
* signal that disables syscall restart on interrupt with clear signal mask
* fun==SIG_DFL also unblocks signal
*/
#if !_UWIN
#undef signal
#define signal ______signal
#endif
#include <ast.h>
#include <sig.h>
#if !_UWIN
#undef signal
#undef _def_map_ast
#include <ast_map.h>
#if defined(__EXPORT__)
#define extern __EXPORT__
#endif
#endif
#if defined(SV_ABORT)
#undef SV_INTERRUPT
#define SV_INTERRUPT SV_ABORT
#endif
#if !_std_signal && (_lib_sigaction && defined(SA_NOCLDSTOP) || _lib_sigvec && defined(SV_INTERRUPT))
#if !defined(SA_NOCLDSTOP) || !defined(SA_INTERRUPT) && defined(SV_INTERRUPT)
#undef SA_INTERRUPT
#define SA_INTERRUPT SV_INTERRUPT
#undef sigaction
#define sigaction sigvec
#undef sigemptyset
#define sigemptyset(p) (*(p)=0)
#undef sa_flags
#define sa_flags sv_flags
#undef sa_handler
#define sa_handler sv_handler
#undef sa_mask
#define sa_mask sv_mask
#endif
extern Sig_handler_t
signal(int sig, Sig_handler_t fun)
{
struct sigaction na;
struct sigaction oa;
#ifdef SIGNO_MASK
unsigned int flags;
#endif
#ifdef SIGNO_MASK
flags = sig & ~SIGNO_MASK;
sig &= SIGNO_MASK;
#endif
if (fun == SIG_DFL)
sigunblock(sig);
memzero(&na, sizeof(na));
na.sa_handler = fun;
#if defined(SA_INTERRUPT) || defined(SA_RESTART)
switch (sig)
{
#if defined(SIGIO) || defined(SIGTSTP) || defined(SIGTTIN) || defined(SIGTTOU)
#if defined(SIGIO)
case SIGIO:
#endif
#if defined(SIGTSTP)
case SIGTSTP:
#endif
#if defined(SIGTTIN)
case SIGTTIN:
#endif
#if defined(SIGTTOU)
case SIGTTOU:
#endif
#if defined(SA_RESTART)
na.sa_flags = SA_RESTART;
#endif
break;
#endif
default:
#if defined(SA_INTERRUPT)
na.sa_flags = SA_INTERRUPT;
#endif
break;
}
#endif
return(sigaction(sig, &na, &oa) ? (Sig_handler_t)0 : oa.sa_handler);
}
#else
NoN(signal)
#endif
|