Interesting. Never heard of usleep before. Could be useful. What is also interesting, whenever I execute usleep in a Fedora Linux bash shell, I get this:
Code:
$ usleep
warning: usleep is deprecated, and will be removed in near future!
warning: use "sleep 1e-06" instead...
_________________ Linksys EA8500 (Internet Gateway, AP/VAP) - DD-WRT r53562
Features in use: WDS-AP, Multiple VLANs, Samba, WireGuard, Entware: mqtt, mlocate
Wireless 5ghz only
Netgear R7800 (WDS-AP, WAP, VAP) - DD-WRT r55779
Features in use: multiple VLANs over single trunk port
Linksys EA8500 WDS Station x2 - DD-WRT r55799
Netgear R6400v2 WAP, VAP 2.4ghz only w/VLANs over single trunk port. DD-WRT r55779
OSes: Fedora 38, 9 RPis (2,3,4,5), 20 ESP8266s: Straight from Amiga to Linux in '94, never having owned a Windows PC.
Joined: 26 Mar 2013 Posts: 1858 Location: Hung Hom, Hong Kong
Posted: Sun Mar 17, 2024 3:18 Post subject:
lexridge wrote:
Interesting. Never heard of usleep before. Could be useful. What is also interesting, whenever I execute usleep in a Fedora Linux bash shell, I get this:
Code:
$ usleep
warning: usleep is deprecated, and will be removed in near future!
warning: use "sleep 1e-06" instead...
Well, both "e" and "-" caused DD-WRT's Ash shell to crash, just like ".". _________________ Router: Asus RT-N18U (rev. A1)
Drink, Blink, Stretch! Live long and prosper! May the Force and farces be with you!
* dd-wrt's busybox has both a shell built-in sleep and /bin/sleep
* /bin/sleep 0.5 dies and returns to the calling ash shell
* sleep 0.5 is built-in so when it dies, ash itself dies
* The code that dies is here (look at 1st line on top)
* Float support exists but not enabled probably to save space
* The sleep function is here and called from ash.c when built-in
You would think that busybox would notice when we are inside of a built-in command and skip over the dying part.
Great find! So it only accepts an integer and not a float, but can accept a float if (re)written properly? _________________ Linksys EA8500 (Internet Gateway, AP/VAP) - DD-WRT r53562
Features in use: WDS-AP, Multiple VLANs, Samba, WireGuard, Entware: mqtt, mlocate
Wireless 5ghz only
Netgear R7800 (WDS-AP, WAP, VAP) - DD-WRT r55779
Features in use: multiple VLANs over single trunk port
Linksys EA8500 WDS Station x2 - DD-WRT r55799
Netgear R6400v2 WAP, VAP 2.4ghz only w/VLANs over single trunk port. DD-WRT r55779
OSes: Fedora 38, 9 RPis (2,3,4,5), 20 ESP8266s: Straight from Amiga to Linux in '94, never having owned a Windows PC.
I built a busybox with CONFIG_FLOAT_DURATION=y and the size is identical to the one I built with float duration disabled (strange, probably needs stripping). The dd-wrt one in /bin is a little smaller but is an older svn revision so hard to compare.
Below I tried sleep 0.5 on dd-wrt's ash, it fails and the shell level drops by one.
I tried sleep 0.5 on my float enabled ash, it works and the shell level remains unchanged.
I tried sleep 0.5 on my float disabled ash, it fails and the shell level drops by one.
Those with openwrt, does sleep 0.5 work or does it give an error message and yet maintain the shell level? Having CONFIG_FLOAT_DURATION disabled is fine but having the entire shell die when it is attempted is not OK.
Pause for a time equal to the total of the args given, where each arg can
have an optional suffix of (s)econds, (m)inutes, (h)ours, or (d)ays
root@OCTEON-TX2:/
Code:
root@DD-WRT:~# sleep 0.5
sh: invalid number '0.5'
Connection to 192.168.1.2 closed.
root@DD-WRT:~# sleep --help
sh: invalid number '--help'
Connection to 192.168.1.2 closed.
Thanks @ho1Aetoo I had seen your openwrt post but still didn't know if float durations were enabled or not. Now I know.
With my dd-wrt build, the type command tells me sleep is a builtin. What does openwrt say. Getting rid of builtin sleep would probably avoid the problem.
Code:
# type sleep
sleep is a shell builtin
# which sleep
/bin/sleep
#