[git commit] runsv: code shrink: use single handler function for SIGTERM and SIGCHLD
Denys Vlasenko
vda.linux at googlemail.com
Sat Jun 5 14:36:21 UTC 2021
commit: https://git.busybox.net/busybox/commit/?id=5a72b0cd74d6de8ed39a9704798ce1118b0995f1
branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master
function old new delta
s_chld_term - 36 +36
runsv_main 1677 1662 -15
s_child 22 - -22
s_term 29 - -29
------------------------------------------------------------------------------
(add/remove: 1/2 grow/shrink: 0/1 up/down: 36/-66) Total: -30 bytes
Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
runit/runsv.c | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
diff --git a/runit/runsv.c b/runit/runsv.c
index 7fad563f5..a4b8af494 100644
--- a/runit/runsv.c
+++ b/runit/runsv.c
@@ -149,20 +149,17 @@ static void warn_cannot(const char *m)
warn2_cannot(m, "");
}
-/* SIGCHLD/TERM handlers are reentrancy-safe because they are unmasked
+/* SIGCHLD/TERM handler is reentrancy-safe because they are unmasked
* only over poll() call, not over memory allocations
* or printouts. Do not need to save/restore errno either,
* as poll() error is not checked there.
*/
-static void s_child(int sig_no UNUSED_PARAM)
+static void s_chld_term(int sig_no)
{
+ if (sig_no == SIGTERM)
+ sigterm = 1;
write(selfpipe.wr, "", 1);
}
-static void s_term(int sig_no UNUSED_PARAM)
-{
- sigterm = 1;
- write(selfpipe.wr, "", 1); /* XXX */
-}
static int open_trunc_or_warn(const char *name)
{
@@ -523,8 +520,10 @@ int runsv_main(int argc UNUSED_PARAM, char **argv)
* (poll() wouldn't restart regardless of that flag),
* we just follow what runit-2.1.2 does:
*/
- bb_signals_norestart(1 << SIGCHLD, s_child);
- bb_signals_norestart(1 << SIGTERM, s_term);
+ bb_signals_norestart(0
+ + (1 << SIGCHLD)
+ + (1 << SIGTERM)
+ , s_chld_term);
xchdir(dir);
/* bss: svd[0].pid = 0; */
More information about the busybox-cvs
mailing list