From ca752127ed614ee2003fda24dab1a36c28f6a800 Mon Sep 17 00:00:00 2001 From: Dave Hylands Date: Fri, 4 Mar 2016 23:50:51 -0800 Subject: Add gettid --- src/unistd.rs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/unistd.rs') diff --git a/src/unistd.rs b/src/unistd.rs index 193086df..5d57afd1 100644 --- a/src/unistd.rs +++ b/src/unistd.rs @@ -56,6 +56,12 @@ pub fn setpgid(pid: pid_t, pgid: pid_t) -> Result<()> { Errno::result(res).map(drop) } +#[cfg(any(target_os = "linux", target_os = "android"))] +#[inline] +pub fn gettid() -> pid_t { + unsafe { libc::syscall(libc::SYS_gettid) as pid_t } // no error handling, according to man page: "These functions are always successful." +} + #[inline] pub fn dup(oldfd: RawFd) -> Result { let res = unsafe { libc::dup(oldfd) }; -- cgit v1.2.3