fish-shell/src/fork_exec
Johannes Altmanninger c1fba4663b Replace nanosleep with stdlib wrapper (which is still broken)
As of rust 1.78, the Unix stdlib implementation is affected by the same issue:

    pub fn sleep(dur: Duration) {
        let mut secs = dur.as_secs();
        let mut nsecs = dur.subsec_nanos() as _;

        // If we're awoken with a signal then the return value will be -1 and
        // nanosleep will fill in `ts` with the remaining time.
        unsafe {
            while secs > 0 || nsecs > 0 {
                let mut ts = libc::timespec {
                    tv_sec: cmp::min(libc::time_t::MAX as u64, secs) as libc::time_t,
                    tv_nsec: nsecs,
                };
                secs -= ts.tv_sec as u64;
                let ts_ptr = core::ptr::addr_of_mut!(ts);
                if libc::nanosleep(ts_ptr, ts_ptr) == -1 {
                    assert_eq!(os::errno(), libc::EINTR);
                    secs += ts.tv_sec as u64;
                    nsecs = ts.tv_nsec;
                } else {
                    nsecs = 0;
                }
            }
        }
    }

Note that there is a small behavior change here -- sleep() will continue
after signals; I'm not sure if we want that but it seems harmless?

Part of #10634
2024-08-07 13:11:22 +02:00
..
flog_safe.rs Clean up some stale comments and restore libc usage in flog_safe 2024-01-21 12:03:56 -08:00
mod.rs
postfork.rs Replace nanosleep with stdlib wrapper (which is still broken) 2024-08-07 13:11:22 +02:00
spawn.rs Remove using statements already imported by preludes 2024-02-28 09:41:51 -06:00