diff options
author | Homu <homu@barosl.com> | 2016-04-14 12:30:40 +0900 |
---|---|---|
committer | Homu <homu@barosl.com> | 2016-04-14 12:30:40 +0900 |
commit | abc7b27920222c6776317b93c13170aa50e1f84a (patch) | |
tree | 736930bdb87bba5c09bfd4eef133ce9ac0820438 | |
parent | 85c53a9ecc251d11305975435ba9b96165912326 (diff) | |
parent | 52790ee2fb7b813ff56704a20190bd36e42e17dd (diff) | |
download | nix-abc7b27920222c6776317b93c13170aa50e1f84a.zip |
Auto merge of #351 - kamalmarhubi:sleep, r=posborne
unistd: Add sleep(3)
-rw-r--r-- | src/unistd.rs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/unistd.rs b/src/unistd.rs index 4a7359cc..c7e88971 100644 --- a/src/unistd.rs +++ b/src/unistd.rs @@ -3,7 +3,7 @@ use {Errno, Error, Result, NixPath}; use fcntl::{fcntl, OFlag, O_NONBLOCK, O_CLOEXEC, FD_CLOEXEC}; use fcntl::FcntlArg::{F_SETFD, F_SETFL}; -use libc::{self, c_char, c_void, c_int, size_t, pid_t, off_t, uid_t, gid_t}; +use libc::{self, c_char, c_void, c_int, c_uint, size_t, pid_t, off_t, uid_t, gid_t}; use std::mem; use std::ffi::CString; use std::os::unix::io::RawFd; @@ -366,6 +366,13 @@ pub fn pause() -> Result<()> { Errno::result(res).map(drop) } +#[inline] +// Per POSIX, does not fail: +// http://pubs.opengroup.org/onlinepubs/009695399/functions/sleep.html#tag_03_705_05 +pub fn sleep(seconds: libc::c_uint) -> c_uint { + unsafe { libc::sleep(seconds) } +} + #[cfg(any(target_os = "linux", target_os = "android"))] mod linux { use sys::syscall::{syscall, SYSPIVOTROOT}; |