Skip to content

Commit 52790ee

Browse files
committed
unistd: Add sleep(3)
1 parent 85c53a9 commit 52790ee

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/unistd.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use {Errno, Error, Result, NixPath};
44
use fcntl::{fcntl, OFlag, O_NONBLOCK, O_CLOEXEC, FD_CLOEXEC};
55
use fcntl::FcntlArg::{F_SETFD, F_SETFL};
6-
use libc::{self, c_char, c_void, c_int, size_t, pid_t, off_t, uid_t, gid_t};
6+
use libc::{self, c_char, c_void, c_int, c_uint, size_t, pid_t, off_t, uid_t, gid_t};
77
use std::mem;
88
use std::ffi::CString;
99
use std::os::unix::io::RawFd;
@@ -366,6 +366,13 @@ pub fn pause() -> Result<()> {
366366
Errno::result(res).map(drop)
367367
}
368368

369+
#[inline]
370+
// Per POSIX, does not fail:
371+
// http://pubs.opengroup.org/onlinepubs/009695399/functions/sleep.html#tag_03_705_05
372+
pub fn sleep(seconds: libc::c_uint) -> c_uint {
373+
unsafe { libc::sleep(seconds) }
374+
}
375+
369376
#[cfg(any(target_os = "linux", target_os = "android"))]
370377
mod linux {
371378
use sys::syscall::{syscall, SYSPIVOTROOT};

0 commit comments

Comments
 (0)