Subject: [PATCH] ash: make 'sleep' a builtin
David Laight
David.Laight at ACULAB.COM
Tue Aug 30 08:10:54 UTC 2022
One question is why?
Shell builtins (mostly) exist to speed things up.
But sleep doesn’t need speeding up.
David
From: busybox <busybox-bounces at busybox.net> On Behalf Of shawnlandden at tutanota.com
Sent: 30 August 2022 02:25
To: Denys Vlasenko <vda.linux at googlemail.com>
Cc: Busybox <busybox at busybox.net>
Subject: Re: Subject: [PATCH] ash: make 'sleep' a builtin
27 ago 2022, 10:36 por vda.linux at googlemail.com<mailto:vda.linux at googlemail.com>:
You forgot this:
//kbuild:lib-$(CONFIG_SLEEP) += sleep.o
+//kbuild:lib-$(CONFIG_ASH_SLEEP) += sleep.o
fixed
/* BB_AUDIT SUSv3 compliant */
/* BB_AUDIT GNU issues -- fancy version matches except args must be ints. */
diff --git a/include/libbb.h b/include/libbb.h
index abbc9ac59..129858e27 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -1511,6 +1511,7 @@ int hush_main(int argc, char** argv)
IF_SHELL_HUSH(MAIN_EXTERNALLY_VISIBLE);
/* If shell needs them, they exist even if not enabled as applets */
int echo_main(int argc, char** argv) IF_ECHO(MAIN_EXTERNALLY_VISIBLE);
int printf_main(int argc, char **argv) IF_PRINTF(MAIN_EXTERNALLY_VISIBLE);
+int sleep_main(int argc, char **argv) IF_SLEEP(MAIN_EXTERNALLY_VISIBLE);
int test_main(int argc, char **argv)
Also, your patch doesn't apply, whitespace damaged by mail agent.
Please resend as attachment.
Hopefully this works.
On Sat, Aug 27, 2022 at 6:25 AM <shawnlandden at tutanota.com<mailto:shawnlandden at tutanota.com>> wrote:
This reduces the number of processes spawned when in an indefinate
do-nothing loop in a shell script.
Signed-off-by: Shawn Landden <shawnlandden at tutanota.com<mailto:shawnlandden at tutanota.com>>
---
shell/ash.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/shell/ash.c b/shell/ash.c
index 55c1034f5..eba7759e7 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -134,6 +134,11 @@
//config: default y
//config: depends on SHELL_ASH
//config:
+//config:config ASH_SLEEP
+//config: bool "sleep builtin"
+//config: default y
+//config: depends on SHELL_ASH
+//config:
//config:config ASH_HELP
//config: bool "help builtin"
//config: default y
@@ -10155,6 +10160,9 @@ static int FAST_FUNC printfcmd(int argc, char **argv) { return printf_main(argc,
#if ENABLE_ASH_TEST || BASH_TEST2
static int FAST_FUNC testcmd(int argc, char **argv) { return test_main(argc, argv); }
#endif
+#if ENABLE_ASH_SLEEP
+static int FAST_FUNC sleepcmd(int argc, char **argv) { return sleep_main(argc, argv); }
+#endif
/* Keep these in proper order since it is searched via bsearch() */
static const struct builtincmd builtintab[] = {
@@ -10217,6 +10225,9 @@ static const struct builtincmd builtintab[] = {
{ BUILTIN_SPEC_REG "return" , returncmd },
{ BUILTIN_SPEC_REG "set" , setcmd },
{ BUILTIN_SPEC_REG "shift" , shiftcmd },
+#if ENABLE_ASH_SLEEP
+ { BUILTIN_REGULAR "sleep" , sleepcmd },
+#endif
#if BASH_SOURCE
{ BUILTIN_SPEC_REG "source" , dotcmd },
#endif
--
2.36.1
_______________________________________________
busybox mailing list
busybox at busybox.net<mailto:busybox at busybox.net>
http://lists.busybox.net/mailman/listinfo/busybox
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/busybox/attachments/20220830/9f299408/attachment-0001.html>
More information about the busybox
mailing list