aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-03-12 23:19:35 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-03-12 23:19:35 +0000
commit8e2cfec1cdf34068f2378aae9fe8f5ec0f821e21 (patch)
treecf328e6b8bbdc608228da528f661124e364edb85 /libbb
parent4cf1d08fc2e50f9abda999d468c5e972ff4995c2 (diff)
downloadbusybox-8e2cfec1cdf34068f2378aae9fe8f5ec0f821e21.tar.gz
libbb: introduse and use signal_[no_]SA_RESTART_empty_mask and sigaction_set
signal_SA_RESTART_empty_mask - 65 +65 signal_no_SA_RESTART_empty_mask - 54 +54 dd_main 1325 1369 +44 sigaction_set - 19 +19 dname_enc 373 377 +4 UNSPEC_print 64 66 +2 setsignal 296 294 -2 bb_signals_recursive 95 92 -3 bb_askpass 367 361 -6 inetd_main 1810 1797 -13 rx_main 912 883 -29 sigdelset 32 - -32 __sigdelset 32 - -32 __GI_sigdelset 32 - -32 sighup_handler 84 37 -47 arping_main 1844 1797 -47 fsck_main 1869 1807 -62 run_list 1917 1844 -73 vlock_main 492 409 -83 progressmeter 883 798 -85 handle_incoming_and_exit 2737 2651 -86 ------------------------------------------------------------------------------ (add/remove: 3/3 grow/shrink: 3/12 up/down: 188/-632) Total: -444 bytes
Diffstat (limited to 'libbb')
-rw-r--r--libbb/bb_askpass.c4
-rw-r--r--libbb/signals.c28
2 files changed, 29 insertions, 3 deletions
diff --git a/libbb/bb_askpass.c b/libbb/bb_askpass.c
index fd12f92dc..3ad0e97cd 100644
--- a/libbb/bb_askpass.c
+++ b/libbb/bb_askpass.c
@@ -45,7 +45,7 @@ char *bb_askpass(int timeout, const char *prompt)
sa.sa_handler = askpass_timeout;
sigaction(SIGINT, &sa, &oldsa);
if (timeout) {
- sigaction(SIGALRM, &sa, NULL);
+ sigaction_set(SIGALRM, &sa);
alarm(timeout);
}
@@ -68,7 +68,7 @@ char *bb_askpass(int timeout, const char *prompt)
if (timeout) {
alarm(0);
}
- sigaction(SIGINT, &oldsa, NULL);
+ sigaction_set(SIGINT, &oldsa);
tcsetattr(STDIN_FILENO, TCSANOW, &oldtio);
bb_putchar('\n');
diff --git a/libbb/signals.c b/libbb/signals.c
index a327e87c8..719beab63 100644
--- a/libbb/signals.c
+++ b/libbb/signals.c
@@ -11,6 +11,12 @@
#include "libbb.h"
+/* Saves 2 bytes on x86! Oh my... */
+int sigaction_set(int signum, const struct sigaction *act)
+{
+ return sigaction(signum, act, NULL);
+}
+
void bb_signals(int sigs, void (*f)(int))
{
int sig_no = 0;
@@ -40,7 +46,7 @@ void bb_signals_recursive(int sigs, void (*f)(int))
while (sigs) {
if (sigs & bit) {
sigs &= ~bit;
- sigaction(sig_no, &sa, NULL);
+ sigaction_set(sig_no, &sa);
}
sig_no++;
bit <<= 1;
@@ -87,3 +93,23 @@ void kill_myself_with_sig(int sig)
raise(sig);
_exit(1); /* Should not reach it */
}
+
+void signal_SA_RESTART_empty_mask(int sig, void (*handler)(int))
+{
+ struct sigaction sa;
+ memset(&sa, 0, sizeof(sa));
+ /*sigemptyset(&sa.sa_mask);*/
+ sa.sa_flags = SA_RESTART;
+ sa.sa_handler = handler;
+ sigaction_set(sig, &sa);
+}
+
+void signal_no_SA_RESTART_empty_mask(int sig, void (*handler)(int))
+{
+ struct sigaction sa;
+ memset(&sa, 0, sizeof(sa));
+ /*sigemptyset(&sa.sa_mask);*/
+ /*sa.sa_flags = 0;*/
+ sa.sa_handler = handler;
+ sigaction_set(sig, &sa);
+}