Merge pull request #1858 from joshtriplett/siginfo-pid-uid
Expose si_pid and si_uid from siginfo_t as functions
This commit is contained in:
commit
6ff0689d88
|
@ -682,6 +682,14 @@ impl siginfo_t {
|
|||
|
||||
(*(self as *const siginfo_t as *const siginfo_timer)).si_value
|
||||
}
|
||||
|
||||
pub unsafe fn si_pid(&self) -> ::pid_t {
|
||||
self.si_pid
|
||||
}
|
||||
|
||||
pub unsafe fn si_uid(&self) -> ::uid_t {
|
||||
self.si_uid
|
||||
}
|
||||
}
|
||||
|
||||
cfg_if! {
|
||||
|
|
|
@ -31,6 +31,14 @@ impl siginfo_t {
|
|||
pub unsafe fn si_value(&self) -> ::sigval {
|
||||
self.si_value
|
||||
}
|
||||
|
||||
pub unsafe fn si_pid(&self) -> ::pid_t {
|
||||
self.si_pid
|
||||
}
|
||||
|
||||
pub unsafe fn si_uid(&self) -> ::uid_t {
|
||||
self.si_uid
|
||||
}
|
||||
}
|
||||
|
||||
s! {
|
||||
|
|
|
@ -38,6 +38,20 @@ impl ::Clone for timezone {
|
|||
}
|
||||
}
|
||||
|
||||
impl siginfo_t {
|
||||
pub unsafe fn si_addr(&self) -> *mut ::c_void {
|
||||
self.si_addr
|
||||
}
|
||||
|
||||
pub unsafe fn si_pid(&self) -> ::pid_t {
|
||||
self.si_pid
|
||||
}
|
||||
|
||||
pub unsafe fn si_uid(&self) -> ::uid_t {
|
||||
self.si_uid
|
||||
}
|
||||
}
|
||||
|
||||
s! {
|
||||
pub struct in_addr {
|
||||
pub s_addr: ::in_addr_t,
|
||||
|
|
|
@ -313,6 +313,63 @@ impl siginfo_t {
|
|||
}
|
||||
}
|
||||
|
||||
cfg_if! {
|
||||
if #[cfg(libc_union)] {
|
||||
// Internal, for casts to access union fields
|
||||
#[repr(C)]
|
||||
#[derive(Copy,Clone)]
|
||||
struct sifields_sigchld {
|
||||
si_pid: ::pid_t,
|
||||
si_uid: ::uid_t,
|
||||
si_status: ::c_int,
|
||||
si_utime: ::c_long,
|
||||
si_stime: ::c_long,
|
||||
}
|
||||
|
||||
// Internal, for casts to access union fields
|
||||
#[repr(C)]
|
||||
union sifields {
|
||||
_align_pointer: *mut ::c_void,
|
||||
sigchld: sifields_sigchld,
|
||||
}
|
||||
|
||||
// Internal, for casts to access union fields. Note that some variants
|
||||
// of sifields start with a pointer, which makes the alignment of
|
||||
// sifields vary on 32-bit and 64-bit architectures.
|
||||
#[repr(C)]
|
||||
struct siginfo_f {
|
||||
_siginfo_base: [::c_int; 3],
|
||||
sifields: sifields,
|
||||
}
|
||||
|
||||
impl siginfo_t {
|
||||
unsafe fn sifields(&self) -> &sifields {
|
||||
&(*(self as *const siginfo_t as *const siginfo_f)).sifields
|
||||
}
|
||||
|
||||
pub unsafe fn si_pid(&self) -> ::pid_t {
|
||||
self.sifields().sigchld.si_pid
|
||||
}
|
||||
|
||||
pub unsafe fn si_uid(&self) -> ::uid_t {
|
||||
self.sifields().sigchld.si_uid
|
||||
}
|
||||
|
||||
pub unsafe fn si_status(&self) -> ::c_int {
|
||||
self.sifields().sigchld.si_status
|
||||
}
|
||||
|
||||
pub unsafe fn si_utime(&self) -> ::c_long {
|
||||
self.sifields().sigchld.si_utime
|
||||
}
|
||||
|
||||
pub unsafe fn si_stime(&self) -> ::c_long {
|
||||
self.sifields().sigchld.si_stime
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
s_no_extra_traits! {
|
||||
pub struct utmpx {
|
||||
pub ut_type: ::c_short,
|
||||
|
|
|
@ -112,6 +112,24 @@ impl ::Clone for _Vx_semaphore {
|
|||
}
|
||||
}
|
||||
|
||||
impl siginfo_t {
|
||||
pub unsafe fn si_addr(&self) -> *mut ::c_void {
|
||||
self.si_addr
|
||||
}
|
||||
|
||||
pub unsafe fn si_value(&self) -> ::sigval {
|
||||
self.si_value
|
||||
}
|
||||
|
||||
pub unsafe fn si_pid(&self) -> ::pid_t {
|
||||
self.si_pid
|
||||
}
|
||||
|
||||
pub unsafe fn si_uid(&self) -> ::uid_t {
|
||||
self.si_uid
|
||||
}
|
||||
}
|
||||
|
||||
s! {
|
||||
// b_pthread_condattr_t.h
|
||||
pub struct pthread_condattr_t {
|
||||
|
|
Loading…
Reference in New Issue