Browse Source

os2: fix bit checks

Laytan Laats 1 year ago
parent
commit
9e2c5acb9d
1 changed files with 7 additions and 2 deletions
  1. 7 2
      core/os/os2/process_posix_darwin.odin

+ 7 - 2
core/os/os2/process_posix_darwin.odin

@@ -54,7 +54,7 @@ _process_info_by_pid :: proc(pid: int, selection: Process_Info_Fields, allocator
 	// other errors usually mean other parts of the info could be retrieved though, so in those cases we keep trying to get the other information.
 	// other errors usually mean other parts of the info could be retrieved though, so in those cases we keep trying to get the other information.
 
 
 	pidinfo: {
 	pidinfo: {
-		if selection >= {.PPid, .Priority, .Username } {
+		if selection & {.PPid, .Priority, .Username } != {} {
 			ppid, mnice, uid, ok := get_pidinfo(pid, selection)
 			ppid, mnice, uid, ok := get_pidinfo(pid, selection)
 			if !ok {
 			if !ok {
 				if err == nil {
 				if err == nil {
@@ -111,7 +111,7 @@ _process_info_by_pid :: proc(pid: int, selection: Process_Info_Fields, allocator
 		}
 		}
 	}
 	}
 
 
-	args: if selection >= { .Command_Line, .Command_Args, .Environment } {
+	args: if selection & { .Command_Line, .Command_Args, .Environment } != {} {
 		mib := []i32{
 		mib := []i32{
 			unix.CTL_KERN,
 			unix.CTL_KERN,
 			unix.KERN_PROCARGS2,
 			unix.KERN_PROCARGS2,
@@ -129,6 +129,11 @@ _process_info_by_pid :: proc(pid: int, selection: Process_Info_Fields, allocator
 		if sysctl(raw_data(mib), 3, raw_data(buf), &length, nil, 0) != .OK {
 		if sysctl(raw_data(mib), 3, raw_data(buf), &length, nil, 0) != .OK {
 			if err == nil {
 			if err == nil {
 				err = _get_platform_error()
 				err = _get_platform_error()
+
+				// Looks like EINVAL is returned here if you don't have permission.
+				if err == Platform_Error(posix.Errno.EINVAL) {
+					err = .Permission_Denied
+				}
 			}
 			}
 			break args
 			break args
 		}
 		}