Skip to content

Commit

Permalink
Auto merge of #351 - kamalmarhubi:sleep, r=posborne
Browse files Browse the repository at this point in the history
unistd: Add sleep(3)
  • Loading branch information
homu committed Apr 14, 2016
2 parents 85c53a9 + 52790ee commit abc7b27
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/unistd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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};
Expand Down

0 comments on commit abc7b27

Please sign in to comment.