19 /* This function will cause system calls to be restarted after signal if possible */
20 SLSig_Fun_Type
*SLsignal (int sig
, SLSig_Fun_Type
*f
)
22 #ifdef SLANG_POSIX_SIGNALS
23 struct sigaction old_sa
, new_sa
;
26 /* We want system calls to be interrupted by SIGALRM. */
27 if (sig
== SIGALRM
) return SLsignal_intr (sig
, f
);
30 sigemptyset (&new_sa
.sa_mask
);
31 new_sa
.sa_handler
= f
;
35 new_sa
.sa_flags
|= SA_RESTART
;
38 if (-1 == sigaction (sig
, &new_sa
, &old_sa
))
39 return (SLSig_Fun_Type
*) SIG_ERR
;
41 return old_sa
.sa_handler
;
44 return signal (sig
, f
);
48 /* This function will NOT cause system calls to be restarted after
51 SLSig_Fun_Type
*SLsignal_intr (int sig
, SLSig_Fun_Type
*f
)
53 #ifdef SLANG_POSIX_SIGNALS
54 struct sigaction old_sa
, new_sa
;
56 sigemptyset (&new_sa
.sa_mask
);
57 new_sa
.sa_handler
= f
;
61 new_sa
.sa_flags
|= SA_INTERRUPT
;
64 if (-1 == sigaction (sig
, &new_sa
, &old_sa
))
65 return (SLSig_Fun_Type
*) SIG_ERR
;
67 return old_sa
.sa_handler
;
70 return signal (sig
, f
);
75 /* We are primarily interested in blocking signals that would cause the
76 * application to reset the tty. These include suspend signals and
77 * possibly interrupt signals.
79 #ifdef SLANG_POSIX_SIGNALS
80 static sigset_t Old_Signal_Mask
;
83 static volatile unsigned int Blocked_Depth
;
85 int SLsig_block_signals (void)
87 #ifdef SLANG_POSIX_SIGNALS
92 if (Blocked_Depth
!= 1)
97 #ifdef SLANG_POSIX_SIGNALS
98 sigemptyset (&new_mask
);
100 sigaddset (&new_mask
, SIGQUIT
);
103 sigaddset (&new_mask
, SIGTSTP
);
106 sigaddset (&new_mask
, SIGINT
);
109 sigaddset (&new_mask
, SIGTTIN
);
112 sigaddset (&new_mask
, SIGTTOU
);
115 (void) sigprocmask (SIG_BLOCK
, &new_mask
, &Old_Signal_Mask
);
118 /* Not implemented. */
123 int SLsig_unblock_signals (void)
125 if (Blocked_Depth
== 0)
130 if (Blocked_Depth
!= 0)
133 #ifdef SLANG_POSIX_SIGNALS
134 (void) sigprocmask (SIG_SETMASK
, &Old_Signal_Mask
, NULL
);