MCPcopy Create free account
hub / github.com/KDAB/GammaRay / checkProcess

Method checkProcess

client/processtracker_macos.cpp:31–74  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29}
30
31void ProcessTrackerBackendMacOS::checkProcess(qint64 pid)
32{
33 GammaRay::ProcessTrackerInfo pinfo(pid);
34 int status;
35 int mib[4];
36 struct kinfo_proc info;
37 size_t size;
38
39 // Initialize the flags so that, if sysctl fails for some bizarre
40 // reason, we get a predictable result.
41 info.kp_proc.p_flag = 0;
42
43 // Initialize mib, which tells sysctl the info we want, in this case
44 // we're looking for information about a specific process ID.
45 mib[0] = CTL_KERN;
46 mib[1] = KERN_PROC;
47 mib[2] = KERN_PROC_PID;
48 mib[3] = pid;
49
50 // Call sysctl.
51 size = sizeof(info);
52 status = sysctl(mib, sizeof(mib) / sizeof(*mib), &info, &size, nullptr, 0);
53
54 if (status == 0) {
55 // We're being debugged if the P_TRACED flag is set.
56 pinfo.traced = (info.kp_proc.p_flag & P_TRACED) != 0;
57
58 switch (info.kp_proc.p_stat) {
59 case SRUN:
60 pinfo.state = GammaRay::ProcessTracker::Running;
61 break;
62 case SSTOP:
63 case SSLEEP:
64 pinfo.state = GammaRay::ProcessTracker::Suspended;
65 break;
66 default:
67 break;
68 }
69 } else {
70 qWarning("%s: Can not sysctl.", Q_FUNC_INFO);
71 }
72
73 emit processChecked(pinfo);
74}

Callers 1

requestUpdateMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected