Skip to content

Commit ddea7ed

Browse files
committed
Expose target pid on Linux.
1 parent a7567c2 commit ddea7ed

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

‎src/lib.rs‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,10 @@ cfg_if! {
142142
pub fn deserialize(_: [u8; 1]) -> Self {
143143
RtPriorityThreadInfo{_dummy: 0}
144144
}
145+
/// Returns the PID of the process containing the thread (fallback: always -1).
146+
pub fn pid(&self) -> i32 {
147+
-1
148+
}
145149
}
146150
/// Fallback implementation that performs no operation for unsupported platforms.
147151
pub fn promote_current_thread_to_real_time_internal(_: u32, audio_samplerate_hz: u32) -> Result<RtPriorityHandle, AudioThreadPriorityError> {

‎src/rt_linux.rs‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ impl RtPriorityThreadInfoInternal {
6262
pub fn deserialize(bytes: [u8; std::mem::size_of::<Self>()]) -> Self {
6363
unsafe { std::mem::transmute::<[u8; std::mem::size_of::<Self>()], Self>(bytes) }
6464
}
65+
/// Returns the PID of the process containing the thread.
66+
pub fn pid(&self) -> libc::pid_t {
67+
self.pid
68+
}
6569
}
6670

6771
impl PartialEq for RtPriorityThreadInfoInternal {

0 commit comments

Comments
 (0)