aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2017-08-16 17:45:32 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2017-08-16 17:45:32 +0200
commite440b39416e7876129e619f7aa6935c783020645 (patch)
tree1507256a61302443f642c3b517a323671441cae8
parentcf686ae3b401c68b64ff997b68b7972881dbf80e (diff)
downloadbusybox-w32-e440b39416e7876129e619f7aa6935c783020645.tar.gz
busybox-w32-e440b39416e7876129e619f7aa6935c783020645.tar.bz2
busybox-w32-e440b39416e7876129e619f7aa6935c783020645.zip
*: stop using atexit in non-debug build: saves ~260 in bss with musl
"builtin" below is atexit's 32-element global array of functions to call. function old new delta top_main 879 889 +10 launch_helper 185 193 +8 powertop_main 1555 1559 +4 sed_main 651 650 -1 slot 4 - -4 call 4 - -4 atexit 23 - -23 kill_helper 31 - -31 __funcs_on_exit 120 - -120 __cxa_atexit 168 - -168 builtin 260 - -260 ------------------------------------------------------------------------------ (add/remove: 0/8 grow/shrink: 3/1 up/down: 22/-611) Total: -589 bytes text data bss dec hex filename 912364 563 6132 919059 e0613 busybox_old 912035 563 5844 918442 e03aa busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--editors/sed.c2
-rw-r--r--mailutils/mail.c21
-rw-r--r--procps/powertop.c14
-rw-r--r--procps/top.c1
4 files changed, 16 insertions, 22 deletions
diff --git a/editors/sed.c b/editors/sed.c
index f68f44724..3fc40ceef 100644
--- a/editors/sed.c
+++ b/editors/sed.c
@@ -1521,7 +1521,7 @@ int sed_main(int argc UNUSED_PARAM, char **argv)
1521 //argc -= optind; 1521 //argc -= optind;
1522 argv += optind; 1522 argv += optind;
1523 if (opt & OPT_in_place) { // -i 1523 if (opt & OPT_in_place) { // -i
1524 atexit(cleanup_outname); 1524 die_func = cleanup_outname;
1525 } 1525 }
1526 if (opt & (2|4)) 1526 if (opt & (2|4))
1527 G.regex_type |= REG_EXTENDED; // -r or -E 1527 G.regex_type |= REG_EXTENDED; // -r or -E
diff --git a/mailutils/mail.c b/mailutils/mail.c
index a7e43c0d1..eceb89071 100644
--- a/mailutils/mail.c
+++ b/mailutils/mail.c
@@ -6,23 +6,15 @@
6 * 6 *
7 * Licensed under GPLv2, see file LICENSE in this source tree. 7 * Licensed under GPLv2, see file LICENSE in this source tree.
8 */ 8 */
9#include <sys/prctl.h>
9#include "libbb.h" 10#include "libbb.h"
10#include "mail.h" 11#include "mail.h"
11 12
12static void kill_helper(void)
13{
14 if (G.helper_pid > 0) {
15 kill(G.helper_pid, SIGTERM);
16 G.helper_pid = 0;
17 }
18}
19
20// generic signal handler 13// generic signal handler
21static void signal_handler(int signo) 14static void signal_handler(int signo)
22{ 15{
23#define err signo 16#define err signo
24 if (SIGALRM == signo) { 17 if (SIGALRM == signo) {
25 kill_helper();
26 bb_error_msg_and_die("timed out"); 18 bb_error_msg_and_die("timed out");
27 } 19 }
28 20
@@ -66,16 +58,15 @@ void FAST_FUNC launch_helper(const char **argv)
66 // child stdout [1] -> parent stdin [0] 58 // child stdout [1] -> parent stdin [0]
67 59
68 if (!G.helper_pid) { 60 if (!G.helper_pid) {
69 // child: try to execute connection helper 61 // child
62 // if parent dies, get SIGTERM
63 prctl(PR_SET_PDEATHSIG, SIGTERM, 0, 0, 0);
64 // try to execute connection helper
70 // NB: SIGCHLD & SIGALRM revert to SIG_DFL on exec 65 // NB: SIGCHLD & SIGALRM revert to SIG_DFL on exec
71 BB_EXECVP_or_die((char**)argv); 66 BB_EXECVP_or_die((char**)argv);
72 } 67 }
73 68
74 // parent 69 // parent goes on
75 // check whether child is alive
76 //redundant:signal_handler(SIGCHLD);
77 // child seems OK -> parent goes on
78 atexit(kill_helper);
79} 70}
80 71
81char* FAST_FUNC send_mail_command(const char *fmt, const char *param) 72char* FAST_FUNC send_mail_command(const char *fmt, const char *param)
diff --git a/procps/powertop.c b/procps/powertop.c
index ebd659bdb..5d522bf91 100644
--- a/procps/powertop.c
+++ b/procps/powertop.c
@@ -8,11 +8,6 @@
8 * 8 *
9 * Licensed under GPLv2, see file LICENSE in this source tree. 9 * Licensed under GPLv2, see file LICENSE in this source tree.
10 */ 10 */
11
12//applet:IF_POWERTOP(APPLET(powertop, BB_DIR_USR_SBIN, BB_SUID_DROP))
13
14//kbuild:lib-$(CONFIG_POWERTOP) += powertop.o
15
16//config:config POWERTOP 11//config:config POWERTOP
17//config: bool "powertop (9.1 kb)" 12//config: bool "powertop (9.1 kb)"
18//config: default y 13//config: default y
@@ -27,6 +22,10 @@
27//config: Without this, powertop will only refresh display every 10 seconds. 22//config: Without this, powertop will only refresh display every 10 seconds.
28//config: No keyboard commands will work, only ^C to terminate. 23//config: No keyboard commands will work, only ^C to terminate.
29 24
25//applet:IF_POWERTOP(APPLET(powertop, BB_DIR_USR_SBIN, BB_SUID_DROP))
26
27//kbuild:lib-$(CONFIG_POWERTOP) += powertop.o
28
30// XXX This should be configurable 29// XXX This should be configurable
31#define ENABLE_FEATURE_POWERTOP_PROCIRQ 1 30#define ENABLE_FEATURE_POWERTOP_PROCIRQ 1
32 31
@@ -718,7 +717,7 @@ int powertop_main(int UNUSED_PARAM argc, char UNUSED_PARAM **argv)
718 set_termios_to_raw(STDIN_FILENO, &G.init_settings, TERMIOS_CLEAR_ISIG); 717 set_termios_to_raw(STDIN_FILENO, &G.init_settings, TERMIOS_CLEAR_ISIG);
719 bb_signals(BB_FATAL_SIGS, sig_handler); 718 bb_signals(BB_FATAL_SIGS, sig_handler);
720 /* So we don't forget to reset term settings */ 719 /* So we don't forget to reset term settings */
721 atexit(reset_term); 720 die_func = reset_term;
722#endif 721#endif
723 722
724 /* Collect initial data */ 723 /* Collect initial data */
@@ -855,6 +854,9 @@ int powertop_main(int UNUSED_PARAM argc, char UNUSED_PARAM **argv)
855 } /* for (;;) */ 854 } /* for (;;) */
856 855
857 bb_putchar('\n'); 856 bb_putchar('\n');
857#if ENABLE_FEATURE_POWERTOP_INTERACTIVE
858 reset_term();
859#endif
858 860
859 return EXIT_SUCCESS; 861 return EXIT_SUCCESS;
860} 862}
diff --git a/procps/top.c b/procps/top.c
index b9958afa0..f97ded5d6 100644
--- a/procps/top.c
+++ b/procps/top.c
@@ -1146,6 +1146,7 @@ int top_main(int argc UNUSED_PARAM, char **argv)
1146 else { 1146 else {
1147 /* Turn on unbuffered input; turn off echoing, ^C ^Z etc */ 1147 /* Turn on unbuffered input; turn off echoing, ^C ^Z etc */
1148 set_termios_to_raw(STDIN_FILENO, &initial_settings, TERMIOS_CLEAR_ISIG); 1148 set_termios_to_raw(STDIN_FILENO, &initial_settings, TERMIOS_CLEAR_ISIG);
1149 die_func = reset_term;
1149 } 1150 }
1150 1151
1151 bb_signals(BB_FATAL_SIGS, sig_catcher); 1152 bb_signals(BB_FATAL_SIGS, sig_catcher);