summaryrefslogtreecommitdiffstats
path: root/darwin
diff options
context:
space:
mode:
authorHisham <hisham@gobolinux.org>2016-03-31 00:18:42 -0300
committerHisham <hisham@gobolinux.org>2016-03-31 00:18:42 -0300
commitd64f2bdd56c287b47b1e0c72e05547bc45b56e4f (patch)
treec54b79e098d743024b795f588f2063522b7f4f36 /darwin
parent3a4c0fa2d60e2354bad25f74fc064c9abf658c48 (diff)
If task_for_pid fails, stop trying.
Diffstat (limited to 'darwin')
-rw-r--r--darwin/DarwinProcess.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/darwin/DarwinProcess.c b/darwin/DarwinProcess.c
index 2bc67448..e1a16f9c 100644
--- a/darwin/DarwinProcess.c
+++ b/darwin/DarwinProcess.c
@@ -26,6 +26,7 @@ typedef struct DarwinProcess_ {
uint64_t utime;
uint64_t stime;
+ bool taskAccess;
} DarwinProcess;
}*/
@@ -47,6 +48,7 @@ DarwinProcess* DarwinProcess_new(Settings* settings) {
this->utime = 0;
this->stime = 0;
+ this->taskAccess = true;
return this;
}
@@ -301,6 +303,10 @@ void DarwinProcess_scanThreads(DarwinProcess *dp) {
Process* proc = (Process*) dp;
kern_return_t ret;
+ if (!dp->taskAccess) {
+ return;
+ }
+
if (proc->state == 'Z') {
return;
}
@@ -308,6 +314,7 @@ void DarwinProcess_scanThreads(DarwinProcess *dp) {
task_t port;
ret = task_for_pid(mach_task_self(), proc->pid, &port);
if (ret != KERN_SUCCESS) {
+ dp->taskAccess = false;
return;
}
@@ -315,6 +322,7 @@ void DarwinProcess_scanThreads(DarwinProcess *dp) {
mach_msg_type_number_t task_info_count = TASK_INFO_MAX;
ret = task_info(port, TASK_BASIC_INFO, (task_info_t) tinfo, &task_info_count);
if (ret != KERN_SUCCESS) {
+ dp->taskAccess = false;
return;
}
@@ -322,6 +330,7 @@ void DarwinProcess_scanThreads(DarwinProcess *dp) {
mach_msg_type_number_t thread_count;
ret = task_threads(port, &thread_list, &thread_count);
if (ret != KERN_SUCCESS) {
+ dp->taskAccess = false;
mach_port_deallocate(mach_task_self(), port);
return;
}

© 2014-2024 Faster IT GmbH | imprint | privacy policy