#[repr(C)]
pub struct taskstats {
Show 44 fields pub version: c_ushort, pub ac_exitcode: c_uint, pub ac_flag: c_uchar, pub ac_nice: c_uchar, pub cpu_count: c_ulonglong, pub cpu_delay_total: c_ulonglong, pub blkio_count: c_ulonglong, pub blkio_delay_total: c_ulonglong, pub swapin_count: c_ulonglong, pub swapin_delay_total: c_ulonglong, pub cpu_run_real_total: c_ulonglong, pub cpu_run_virtual_total: c_ulonglong, pub ac_comm: [c_char; 32], pub ac_sched: c_uchar, pub ac_pad: [c_uchar; 3], pub __unused_padding: u32, pub ac_uid: c_uint, pub ac_gid: c_uint, pub ac_pid: c_uint, pub ac_ppid: c_uint, pub ac_btime: c_uint, pub ac_etime: c_ulonglong, pub ac_utime: c_ulonglong, pub ac_stime: c_ulonglong, pub ac_minflt: c_ulonglong, pub ac_majflt: c_ulonglong, pub coremem: c_ulonglong, pub virtmem: c_ulonglong, pub hiwater_rss: c_ulonglong, pub hiwater_vm: c_ulonglong, pub read_char: c_ulonglong, pub write_char: c_ulonglong, pub read_syscalls: c_ulonglong, pub write_syscalls: c_ulonglong, pub read_bytes: c_ulonglong, pub write_bytes: c_ulonglong, pub cancelled_write_bytes: c_ulonglong, pub nvcsw: c_ulonglong, pub nivcsw: c_ulonglong, pub ac_utimescaled: c_ulonglong, pub ac_stimescaled: c_ulonglong, pub cpu_scaled_run_real_total: c_ulonglong, pub freepages_count: c_ulonglong, pub freepages_delay_total: c_ulonglong,
}
Expand description

This is custom copy of the generated struct taskstats from linux version 3.10.0 and in this crate this type is used to read binary data transferred from linux kernel. The reason of doing this despite the bindgen generates rust bindings including struct taskstats is due to potential corruption of on-memory struct layout likely caused by old clang version. ref: https://github.com/rust-lang/rust-bindgen/issues/867 Specifically, when bindgen generates struct taskstats with older clang version, the resulting struct defined in generated rust source code contains size padding as the last member of the struct causing offset of members after ac_uid to shift 4-byte or more and the result data becomes unreliable. The bindgen generated definition works well in environment that uses newer clang versions, but I decided to use copied definition of this struct for the time being by following considerations:

  • The struct definition rarely evolves.
  • Returning corrupted data silently is critical and much worse than not providing from the beginning.
  • If user of this crate still needs to access the exactly original definition generated by bindgen, it might still be possible by casting type to __bindgen_taskstats exported by this crate.

Fields§

§version: c_ushort§ac_exitcode: c_uint§ac_flag: c_uchar§ac_nice: c_uchar§cpu_count: c_ulonglong§cpu_delay_total: c_ulonglong§blkio_count: c_ulonglong§blkio_delay_total: c_ulonglong§swapin_count: c_ulonglong§swapin_delay_total: c_ulonglong§cpu_run_real_total: c_ulonglong§cpu_run_virtual_total: c_ulonglong§ac_comm: [c_char; 32]§ac_sched: c_uchar§ac_pad: [c_uchar; 3]§__unused_padding: u32§ac_uid: c_uint§ac_gid: c_uint§ac_pid: c_uint§ac_ppid: c_uint§ac_btime: c_uint§ac_etime: c_ulonglong§ac_utime: c_ulonglong§ac_stime: c_ulonglong§ac_minflt: c_ulonglong§ac_majflt: c_ulonglong§coremem: c_ulonglong§virtmem: c_ulonglong§hiwater_rss: c_ulonglong§hiwater_vm: c_ulonglong§read_char: c_ulonglong§write_char: c_ulonglong§read_syscalls: c_ulonglong§write_syscalls: c_ulonglong§read_bytes: c_ulonglong§write_bytes: c_ulonglong§cancelled_write_bytes: c_ulonglong§nvcsw: c_ulonglong§nivcsw: c_ulonglong§ac_utimescaled: c_ulonglong§ac_stimescaled: c_ulonglong§cpu_scaled_run_real_total: c_ulonglong§freepages_count: c_ulonglong§freepages_delay_total: c_ulonglong

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.