Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions src/uucore/src/lib/features/process/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,16 +230,15 @@ mod timer {

pub(super) fn arm(&mut self, timeout: Duration) -> Result<(), io::Error> {
let timeout = timeout.min(MAX_KTIME_T).max(Duration::from_micros(1));
let time = libc::itimerspec {
it_interval: libc::timespec {
tv_sec: 0,
tv_nsec: 0,
},
it_value: libc::timespec {
tv_sec: timeout.as_secs() as _,
tv_nsec: timeout.subsec_nanos() as _,
},
// `timespec` has private padding members on time64 targets, so its
// fields cannot be listed in a struct literal; start from the
// zeroed default and fill in the ones we care about.
let mut time = libc::itimerspec {
it_interval: libc::timespec::default(),
it_value: libc::timespec::default(),
};
Comment on lines +236 to 239
time.it_value.tv_sec = timeout.as_secs() as _;
time.it_value.tv_nsec = timeout.subsec_nanos() as _;

// SAFETY: All values are properly initialized.
if unsafe { libc::timer_settime(self.0, 0, &raw const time, null_mut()) } == -1 {
Expand Down
Loading