mirror of
https://github.com/odin-lang/Odin.git
synced 2025-12-31 18:32:12 +00:00
os2: nice != priority
This commit is contained in:
@@ -22,16 +22,16 @@ foreign lib {
|
||||
_process_info_by_pid :: proc(pid: int, selection: Process_Info_Fields, allocator: runtime.Allocator) -> (info: Process_Info, err: Error) {
|
||||
info.pid = pid
|
||||
|
||||
get_pidinfo :: proc(pid: int, selection: Process_Info_Fields) -> (ppid: u32, nice: Maybe(i32), uid: posix.uid_t, ok: bool) {
|
||||
get_pidinfo :: proc(pid: int, selection: Process_Info_Fields) -> (ppid: u32, prio: Maybe(i32), uid: posix.uid_t, ok: bool) {
|
||||
// Short info is enough and requires less permissions if the priority isn't requested.
|
||||
if .Priority in selection {
|
||||
pinfo: darwin.proc_bsdinfo
|
||||
ret := darwin.proc_pidinfo(posix.pid_t(pid), .BSDINFO, 0, &pinfo, size_of(pinfo))
|
||||
info: darwin.proc_taskallinfo
|
||||
ret := darwin.proc_pidinfo(posix.pid_t(pid), .TASKALLINFO, 0, &info, size_of(info))
|
||||
if ret > 0 {
|
||||
assert(ret == size_of(pinfo))
|
||||
ppid = pinfo.pbi_ppid
|
||||
nice = pinfo.pbi_nice
|
||||
uid = pinfo.pbi_uid
|
||||
assert(ret == size_of(info))
|
||||
ppid = info.pbsd.pbi_ppid
|
||||
prio = info.ptinfo.pti_priority
|
||||
uid = info.pbsd.pbi_uid
|
||||
ok = true
|
||||
return
|
||||
}
|
||||
@@ -55,7 +55,7 @@ _process_info_by_pid :: proc(pid: int, selection: Process_Info_Fields, allocator
|
||||
|
||||
pidinfo: {
|
||||
if selection & {.PPid, .Priority, .Username } != {} {
|
||||
ppid, mnice, uid, ok := get_pidinfo(pid, selection)
|
||||
ppid, mprio, uid, ok := get_pidinfo(pid, selection)
|
||||
if !ok {
|
||||
if err == nil {
|
||||
err = _get_platform_error()
|
||||
@@ -68,8 +68,8 @@ _process_info_by_pid :: proc(pid: int, selection: Process_Info_Fields, allocator
|
||||
info.fields += {.PPid}
|
||||
}
|
||||
|
||||
if nice, has_nice := mnice.?; has_nice && .Priority in selection {
|
||||
info.priority = int(nice)
|
||||
if prio, has_prio := mprio.?; has_prio && .Priority in selection {
|
||||
info.priority = int(prio)
|
||||
info.fields += {.Priority}
|
||||
}
|
||||
|
||||
|
||||
@@ -98,6 +98,32 @@ vinfo_stat :: struct {
|
||||
vst_qspare: [2]i64,
|
||||
}
|
||||
|
||||
proc_taskinfo :: struct {
|
||||
pti_virtual_size: u64 `fmt:"M"`,
|
||||
pti_resident_size: u64 `fmt:"M"`,
|
||||
pti_total_user: u64,
|
||||
pti_total_system: u64,
|
||||
pti_threads_user: u64,
|
||||
pti_threads_system: u64,
|
||||
pti_policy: i32,
|
||||
pti_faults: i32,
|
||||
pti_pageins: i32,
|
||||
pti_cow_faults: i32,
|
||||
pti_messages_sent: i32,
|
||||
pti_messages_received: i32,
|
||||
pti_syscalls_mach: i32,
|
||||
pti_syscalls_unix: i32,
|
||||
pti_csw: i32,
|
||||
pti_threadnum: i32,
|
||||
pti_numrunning: i32,
|
||||
pti_priority: i32,
|
||||
}
|
||||
|
||||
proc_taskallinfo :: struct {
|
||||
pbsd: proc_bsdinfo,
|
||||
ptinfo: proc_taskinfo,
|
||||
}
|
||||
|
||||
fsid_t :: distinct [2]i32
|
||||
|
||||
PBI_Flag_Bits :: enum u32 {
|
||||
|
||||
Reference in New Issue
Block a user