]>
git.proxmox.com Git - rustc.git/blob - vendor/rustix-0.37.22/src/thread/id.rs
1 use crate::process
::{Gid, Pid, Uid}
;
2 use crate::{backend, io}
;
4 /// `gettid()`—Returns the thread ID.
6 /// This returns the OS thread ID, which is not necessarily the same as the
7 /// `rust::thread::Thread::id` or the pthread ID.
12 /// [Linux]: https://man7.org/linux/man-pages/man2/gettid.2.html
15 pub fn gettid() -> Pid
{
16 backend
::thread
::syscalls
::gettid()
23 /// This is not the setxid you are looking for... POSIX requires xids to be
24 /// process granular, but on Linux they are per-thread. Thus, this call only
25 /// changes the xid for the current *thread*, not the entire process even
26 /// though that is in violation of the POSIX standard.
28 /// For details on this distinction, see the C library vs. kernel differences
29 /// in the [manual page][linux_notes]. This call implements the kernel
36 /// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/setuid.html
37 /// [Linux]: https://man7.org/linux/man-pages/man2/setuid.2.html
38 /// [linux_notes]: https://man7.org/linux/man-pages/man2/setuid.2.html#NOTES
40 pub fn set_thread_uid(uid
: Uid
) -> io
::Result
<()> {
41 backend
::thread
::syscalls
::setuid_thread(uid
)
44 /// `setresuid(ruid, euid, suid)`
48 /// This is not the setresxid you are looking for... POSIX requires xids to be
49 /// process granular, but on Linux they are per-thread. Thus, this call only
50 /// changes the xid for the current *thread*, not the entire process even
51 /// though that is in violation of the POSIX standard.
53 /// For details on this distinction, see the C library vs. kernel differences
54 /// in the [manual page][linux_notes] and the notes in [`set_thread_uid`]. This
55 /// call implements the kernel behavior.
60 /// [Linux]: https://man7.org/linux/man-pages/man2/setresuid.2.html
61 /// [linux_notes]: https://man7.org/linux/man-pages/man2/setresuid.2.html#NOTES
63 pub fn set_thread_res_uid(ruid
: Uid
, euid
: Uid
, suid
: Uid
) -> io
::Result
<()> {
64 backend
::thread
::syscalls
::setresuid_thread(ruid
, euid
, suid
)
71 /// This is not the setxid you are looking for... POSIX requires xids to be
72 /// process granular, but on Linux they are per-thread. Thus, this call only
73 /// changes the xid for the current *thread*, not the entire process even
74 /// though that is in violation of the POSIX standard.
76 /// For details on this distinction, see the C library vs. kernel differences
77 /// in the [manual page][linux_notes]. This call implements the kernel
84 /// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/setgid.html
85 /// [Linux]: https://man7.org/linux/man-pages/man2/setgid.2.html
86 /// [linux_notes]: https://man7.org/linux/man-pages/man2/setgid.2.html#NOTES
88 pub fn set_thread_gid(gid
: Gid
) -> io
::Result
<()> {
89 backend
::thread
::syscalls
::setgid_thread(gid
)
92 /// `setresgid(rgid, egid, sgid)`
96 /// This is not the setresxid you are looking for... POSIX requires xids to be
97 /// process granular, but on Linux they are per-thread. Thus, this call only
98 /// changes the xid for the current *thread*, not the entire process even
99 /// though that is in violation of the POSIX standard.
101 /// For details on this distinction, see the C library vs. kernel differences
102 /// in the [manual page][linux_notes] and the notes in [`set_thread_gid`]. This
103 /// call implements the kernel behavior.
108 /// [Linux]: https://man7.org/linux/man-pages/man2/setresgid.2.html
109 /// [linux_notes]: https://man7.org/linux/man-pages/man2/setresgid.2.html#NOTES
111 pub fn set_thread_res_gid(rgid
: Gid
, egid
: Gid
, sgid
: Gid
) -> io
::Result
<()> {
112 backend
::thread
::syscalls
::setresgid_thread(rgid
, egid
, sgid
)