diff options
author | Dave Hylands <dhylands@gmail.com> | 2016-03-04 23:50:51 -0800 |
---|---|---|
committer | Dave Hylands <dhylands@gmail.com> | 2016-03-07 20:41:38 -0800 |
commit | ca752127ed614ee2003fda24dab1a36c28f6a800 (patch) | |
tree | 18a0f849c1d7d379e4e63f0b5491138371efc819 /src/unistd.rs | |
parent | 3f0c3e13a22379dccbe826336f1805a98cf6cecc (diff) | |
download | nix-ca752127ed614ee2003fda24dab1a36c28f6a800.zip |
Add gettid
Diffstat (limited to 'src/unistd.rs')
-rw-r--r-- | src/unistd.rs | 6 |
1 files changed, 6 insertions, 0 deletions
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<RawFd> { let res = unsafe { libc::dup(oldfd) }; |