aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2023-07-10 10:52:41 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2023-07-10 10:53:23 +0200
commit5e0411a7fb510b9aecda0a850c76bdd62c50efa4 (patch)
treed3698f53c76998c940131e18aca0cf5e025c6605
parent6ce1dc2e91398145633ceaff7a6fecc786826277 (diff)
downloadbusybox-w32-5e0411a7fb510b9aecda0a850c76bdd62c50efa4.tar.gz
busybox-w32-5e0411a7fb510b9aecda0a850c76bdd62c50efa4.tar.bz2
busybox-w32-5e0411a7fb510b9aecda0a850c76bdd62c50efa4.zip
ash: disable sleep as builtin, closes 15619
Has a few annoying problems: * sleepcmd() -> sleep_main(), the parsing of bad arguments exits the shell. * sleep_for_duration() in sleep_main() has to be interruptible for ^C traps to work, which may be a problem for other users of sleep_for_duration(). * BUT, if sleep_for_duration() is interruptible, then SIGCHLD interrupts it as well (try "/bin/sleep 1 & sleep 10"). * sleep_main() must not allocate anything as ^C in ash longjmp's. (currently, allocations are only on error paths, in message printing). Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--include/libbb.h2
-rw-r--r--shell/ash.c22
2 files changed, 19 insertions, 5 deletions
diff --git a/include/libbb.h b/include/libbb.h
index 18336da23..640fa3988 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -1513,6 +1513,8 @@ int hush_main(int argc, char** argv) IF_SHELL_HUSH(MAIN_EXTERNALLY_VISIBLE);
1513/* If shell needs them, they exist even if not enabled as applets */ 1513/* If shell needs them, they exist even if not enabled as applets */
1514int echo_main(int argc, char** argv) IF_ECHO(MAIN_EXTERNALLY_VISIBLE); 1514int echo_main(int argc, char** argv) IF_ECHO(MAIN_EXTERNALLY_VISIBLE);
1515int sleep_main(int argc, char **argv) IF_SLEEP(MAIN_EXTERNALLY_VISIBLE); 1515int sleep_main(int argc, char **argv) IF_SLEEP(MAIN_EXTERNALLY_VISIBLE);
1516/* See disabled "config ASH_SLEEP" in ash.c */
1517#define ENABLE_ASH_SLEEP 0
1516int printf_main(int argc, char **argv) IF_PRINTF(MAIN_EXTERNALLY_VISIBLE); 1518int printf_main(int argc, char **argv) IF_PRINTF(MAIN_EXTERNALLY_VISIBLE);
1517int test_main(int argc, char **argv) 1519int test_main(int argc, char **argv)
1518#if ENABLE_TEST || ENABLE_TEST1 || ENABLE_TEST2 1520#if ENABLE_TEST || ENABLE_TEST1 || ENABLE_TEST2
diff --git a/shell/ash.c b/shell/ash.c
index e91566994..e154cc6cc 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -134,11 +134,23 @@
134//config: default y 134//config: default y
135//config: depends on SHELL_ASH 135//config: depends on SHELL_ASH
136//config: 136//config:
137//config:config ASH_SLEEP 137//
138//config: bool "sleep builtin" 138////config:config ASH_SLEEP
139//config: default y 139////config: bool "sleep builtin"
140//config: depends on SHELL_ASH 140////config: default y
141//config: 141////config: depends on SHELL_ASH
142////config:
143//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
144//Disabled for now. Has a few annoying problems:
145// * sleepcmd() -> sleep_main(), the parsing of bad arguments exits the shell.
146// * sleep_for_duration() in sleep_main() has to be interruptible for
147// ^C traps to work, which may be a problem for other users
148// of sleep_for_duration().
149// * BUT, if sleep_for_duration() is interruptible, then SIGCHLD interrupts it
150// as well (try "/bin/sleep 1 & sleep 10").
151// * sleep_main() must not allocate anything as ^C in ash longjmp's.
152// (currently, allocations are only on error paths, in message printing).
153//
142//config:config ASH_HELP 154//config:config ASH_HELP
143//config: bool "help builtin" 155//config: bool "help builtin"
144//config: default y 156//config: default y