summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHomu <homu@barosl.com>2016-03-09 00:30:52 +0900
committerHomu <homu@barosl.com>2016-03-09 00:30:52 +0900
commit1380807f6965f019dd63d61fad6570fc70eadf66 (patch)
tree18a0f849c1d7d379e4e63f0b5491138371efc819 /src
parent3f0c3e13a22379dccbe826336f1805a98cf6cecc (diff)
parentca752127ed614ee2003fda24dab1a36c28f6a800 (diff)
downloadnix-1380807f6965f019dd63d61fad6570fc70eadf66.zip
Auto merge of #293 - dhylands:gettid, r=kamalmarhubi
Add gettid I tested this under linux, and I noticed that this seems to also be built for OSX. It would be appreciated if someone could test this under OSX. I'm not familiar enough with rust to know if there is a way of integrating this without creating a sub-crate.
Diffstat (limited to 'src')
-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) };