36 #if !defined(lint) && !defined(SCCSID)
38 static char sccsid[] =
"@(#)sig.c 8.1 (Berkeley) 6/4/93";
53 private const int sighdl[] = {
60 private void sig_handler(
int);
68 sig_handler(
int signo)
73 (void) sigemptyset(&nset);
74 (void) sigaddset(&nset, signo);
75 (void) sigprocmask(SIG_BLOCK, &nset, &oset);
77 sel->el_signal->sig_no = signo;
82 if (ed_redisplay(sel, 0) == CC_REFRESH)
96 for (i = 0; sighdl[
i] != -1; i++)
97 if (signo == sighdl[i])
100 (void)
sigaction(signo, &sel->el_signal->sig_action[i], NULL);
101 sel->el_signal->sig_action[
i].sa_handler = SIG_ERR;
102 sel->el_signal->sig_action[
i].sa_flags = 0;
103 sigemptyset(&sel->el_signal->sig_action[i].sa_mask);
104 (void) sigprocmask(SIG_SETMASK, &oset, NULL);
105 (void)
kill(0, signo);
116 sigset_t *nset, oset;
118 el->el_signal = el_malloc(
sizeof(*el->el_signal));
119 if (el->el_signal == NULL)
122 nset = &el->el_signal->sig_set;
123 (void) sigemptyset(nset);
124 #define _DO(a) (void) sigaddset(nset, a);
127 (void) sigprocmask(SIG_BLOCK, nset, &oset);
129 for (i = 0; sighdl[
i] != -1; i++) {
130 el->el_signal->sig_action[
i].sa_handler = SIG_ERR;
131 el->el_signal->sig_action[
i].sa_flags = 0;
132 sigemptyset(&el->el_signal->sig_action[i].sa_mask);
135 (void) sigprocmask(SIG_SETMASK, &oset, NULL);
148 el_free(el->el_signal);
149 el->el_signal = NULL;
163 nsa.sa_handler = sig_handler;
165 sigemptyset(&nsa.sa_mask);
167 (void) sigprocmask(SIG_BLOCK, &el->el_signal->sig_set, &oset);
169 for (i = 0; sighdl[
i] != -1; i++) {
171 if (
sigaction(sighdl[i], &nsa, &osa) != -1 &&
172 osa.sa_handler != sig_handler)
173 el->el_signal->sig_action[i] = osa;
176 (void) sigprocmask(SIG_SETMASK, &oset, NULL);
189 (void) sigprocmask(SIG_BLOCK, &el->el_signal->sig_set, &oset);
191 for (i = 0; sighdl[
i] != -1; i++)
192 if (el->el_signal->sig_action[i].sa_handler != SIG_ERR)
194 &el->el_signal->sig_action[i], NULL);
198 (void)sigprocmask(SIG_SETMASK, &oset, NULL);