From ddea7ed28a25a4b878b1ac12d67b827ec4e59f64 Mon Sep 17 00:00:00 2001 From: Matthew Gregan Date: Fri, 10 Apr 2026 15:59:51 +1200 Subject: [PATCH] Expose target pid on Linux. --- src/lib.rs | 4 ++++ src/rt_linux.rs | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 76cc2b5..613f5c1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -142,6 +142,10 @@ cfg_if! { pub fn deserialize(_: [u8; 1]) -> Self { RtPriorityThreadInfo{_dummy: 0} } + /// Returns the PID of the process containing the thread (fallback: always -1). + pub fn pid(&self) -> i32 { + -1 + } } /// Fallback implementation that performs no operation for unsupported platforms. pub fn promote_current_thread_to_real_time_internal(_: u32, audio_samplerate_hz: u32) -> Result { diff --git a/src/rt_linux.rs b/src/rt_linux.rs index 1eabe29..2a1ddb0 100644 --- a/src/rt_linux.rs +++ b/src/rt_linux.rs @@ -62,6 +62,10 @@ impl RtPriorityThreadInfoInternal { pub fn deserialize(bytes: [u8; std::mem::size_of::()]) -> Self { unsafe { std::mem::transmute::<[u8; std::mem::size_of::()], Self>(bytes) } } + /// Returns the PID of the process containing the thread. + pub fn pid(&self) -> libc::pid_t { + self.pid + } } impl PartialEq for RtPriorityThreadInfoInternal {