Odin icon indicating copy to clipboard operation
Odin copied to clipboard

Unix time.sleep sleeps forever when given negative duration of at least a second

Open khvorov45 opened this issue 4 years ago • 1 comments

Context

  • linux mint
  • odin version dev-2021-10:06f47621

Expected Behavior

Expected time.sleep to not sleep at all when given negative duration

Current Behavior

Sleeps forever when given a negative duration of at least a second. Presumably because it casts seconds as u32

// core/time/time_unix.odin
sleep :: proc(d: Duration) {
	ds := duration_seconds(d)
	seconds := u32(ds)
	nanoseconds := i64((ds - f64(seconds)) * 1e9)

	if seconds > 0     { _unix_sleep(seconds)   }
	if nanoseconds > 0 { nanosleep(nanoseconds) }
}

Steps to Reproduce

package test

import "core:time"

main :: proc() {
    time.sleep(-1 * time.Second)
}

khvorov45 avatar Oct 24 '21 02:10 khvorov45

Hello!

I am marking this issue as stale as it has not received any engagement from the community or maintainers 120 days. That does not imply that the issue has no merit! If you feel strongly about this issue

  • open a PR referencing and resolving the issue;
  • leave a comment on it and discuss ideas how you could contribute towards resolving it;
  • leave a comment and describe in detail why this issue is critical for your use case;
  • open a new issue with updated details and a plan on resolving the issue.

The motivation for this automation is to help prioritize issues in the backlog and not ignore, reject, or belittle anyone..

github-actions[bot] avatar Jul 24 '22 21:07 github-actions[bot]