Bug 16024

Summary: ash: sleep as a builtin may abort the shell
Product: Busybox Reporter: Paul <sinbad_4273>
Component: OtherAssignee: unassigned
Status: NEW ---    
Severity: normal CC: busybox-cvs
Priority: P5    
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: Linux   
Host: Target:
Build:

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.