int sigaction_set(int sig, const struct sigaction *act) FAST_FUNC;
/* SIG_BLOCK/SIG_UNBLOCK all signals: */
int sigprocmask_allsigs(int how) FAST_FUNC;
+/* SIG_SETMASK set, and return old set in the same set: */
+int sigprocmask_SIG_SETMASK(sigset_t *set) FAST_FUNC;
/* Standard handler which just records signo */
extern smallint bb_got_signal;
void record_signo(int signo); /* not FAST_FUNC! */
}
#endif
+static void sigaction2(int sig, struct sigaction *act)
+{
+ // Grr... gcc 8.1.1:
+ // "passing argument 3 to restrict-qualified parameter aliases with argument 2"
+ // dance around that...
+ struct sigaction *oact FIX_ALIASING;
+ oact = act;
+ sigaction(sig, act, oact);
+}
+
/* maxsize must be >= 2.
* Returns:
* -1 on read errors or EOF, or on bare Ctrl-D,
/* Install window resize handler (NB: after *all* init is complete) */
S.SIGWINCH_handler.sa_handler = win_changed;
S.SIGWINCH_handler.sa_flags = SA_RESTART;
- sigaction(SIGWINCH, &S.SIGWINCH_handler, &S.SIGWINCH_handler);
+ sigaction2(SIGWINCH, &S.SIGWINCH_handler);
#endif
read_key_buffer[0] = 0;
while (1) {
return sigprocmask(how, &set, NULL);
}
+int FAST_FUNC sigprocmask_SIG_SETMASK(sigset_t *set)
+{
+ // Grr... gcc 8.1.1:
+ // "passing argument 3 to restrict-qualified parameter aliases with argument 2"
+ // dance around that...
+ sigset_t *oset FIX_ALIASING;
+ oset = set;
+ return sigprocmask(SIG_SETMASK, set, oset);
+}
+
void FAST_FUNC bb_signals(int sigs, void (*f)(int))
{
int sig_no = 0;
/* Children exist, but none are ready. Sleep until interesting signal */
#if 1
sigfillset(&mask);
- sigprocmask(SIG_SETMASK, &mask, &mask);
+ sigprocmask_SIG_SETMASK(&mask); /* mask is updated */
while (!got_sigchld && !pending_sig)
sigsuspend(&mask);
sigprocmask(SIG_SETMASK, &mask, NULL);
* and get stuck in sigsuspend...
*/
sigfillset(&oldset); /* block all signals, remember old set */
- sigprocmask(SIG_SETMASK, &oldset, &oldset);
+ sigprocmask_SIG_SETMASK(&oldset);
if (!sigisemptyset(&G.pending_set)) {
/* Crap! we raced with some signal! */