Page MenuHomeFreeBSD

sleep: fix SIGINFO output and modernize interval parsing
Needs ReviewPublic

Authored by nvsrahul_hotmail.com on Sun, Jan 18, 12:47 PM.
Tags
None
Referenced Files
F142364492: D54765.id170003.diff
Mon, Jan 19, 3:10 AM
F142361301: D54765.diff
Mon, Jan 19, 2:00 AM
F142361271: D54765.diff
Mon, Jan 19, 2:00 AM
F142361160: D54765.id169995.diff
Mon, Jan 19, 1:57 AM
F142357284: D54765.id.diff
Mon, Jan 19, 12:30 AM
F142356529: D54765.id170001.diff
Mon, Jan 19, 12:14 AM
F142356085: D54765.id169998.largetrue.diff
Mon, Jan 19, 12:05 AM
F142354798: D54765.id169998.largetrue.diff
Sun, Jan 18, 11:37 PM
Subscribers

Details

Reviewers
imp
pouria
delphij
Group Reviewers
network
NetApp
Klara
Summary

Replace sscanf-based interval parsing with strtod(3) to match
documented behavior and improve error handling. Fix SIGINFO
handling to print remaining sleep time to stdout as specified
by sleep(1).

Signed-off-by: NVSRahul <nvsrahul@hotmail.com>

Test Plan

Tested interval parsing with integer and fractional values
using s, m, h, and d units. Verified invalid inputs are rejected.
Confirmed SIGINFO output is printed to stdout and works correctly
with stdout redirection.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 69971
Build 66854: arc lint + arc unit

Event Timeline

  • sleep: fix SIGINFO output and modernize interval parsing

Updating D54765: sleep: fix SIGINFO output and modernize interval parsing

Updating D54765: sleep: fix SIGINFO output and modernize interval parsing

Updating D54765: sleep: fix SIGINFO output and modernize interval parsing

Updating D54765: sleep: fix SIGINFO output and modernize interval parsing

Updating D54765: sleep: fix SIGINFO output and modernize interval parsing

Updated D54765: sleep: fix SIGINFO output and modernize interval parsing

bin/sleep/sleep.c
92

So if endptr[0] was NUL, what guarantees endptr[1] is also NUL.

Updated D54765: sleep: fix SIGINFO output and modernize interval parsing

Good catch, thanks.
When *endptr == '\0', accessing endptr[1] is invalid.
I’ve updated the logic to only check endptr[1] when a unit
character is present, avoiding a read past the string terminator.