summaryrefslogtreecommitdiff
path: root/src/unistd.rs
diff options
context:
space:
mode:
authorDave Hylands <dhylands@gmail.com>2016-03-04 23:50:51 -0800
committerDave Hylands <dhylands@gmail.com>2016-03-07 20:41:38 -0800
commitca752127ed614ee2003fda24dab1a36c28f6a800 (patch)
tree18a0f849c1d7d379e4e63f0b5491138371efc819 /src/unistd.rs
parent3f0c3e13a22379dccbe826336f1805a98cf6cecc (diff)
downloadnix-ca752127ed614ee2003fda24dab1a36c28f6a800.zip
Add gettid
Diffstat (limited to 'src/unistd.rs')
-rw-r--r--src/unistd.rs6
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) };