Bug 16024 - ash: sleep as a builtin may abort the shell
Summary: ash: sleep as a builtin may abort the shell
Status: NEW
Alias: None
Product: Busybox
Classification: Unclassified
Component: Other (show other bugs)
Version: unspecified
Hardware: All Linux
: P5 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-04-09 14:51 UTC by Paul
Modified: 2024-04-09 14:51 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Paul 2024-04-09 14:51:46 UTC
For ash builtin sleep, the following aborts the shell

sleep --help   // if help isn't on
sleep 0.5      // if float duration isn't on
sleep 1n       // typo should have been 1m with fancy sleep on

This is known to busybox developers as shown by this comment in sleep.c
//FIXME: in ash, "sleep 123qwerty" as a builtin aborts the shell
https://git.busybox.net/busybox/tree/coreutils/sleep.c#n91

If any sleep argument is deemed invalid, bb_error_msg_and_die() is called but in the case of a builtin the entire ash shell is what dies not sleep as intended.
https://git.busybox.net/busybox/tree/libbb/xatonum_template.c#n74

This was noticed in the dd-wrt project as discussed here:
https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=336142

Workaround:
Use /bin/sleep instead of builtin sleep so bb_error_msg_and_die() will terminate the sleep process not the terminate the ash process.