From 31b71b67011fa52f091df6fe536a11d6d0bfb256 Mon Sep 17 00:00:00 2001 From: Daniel Lange Date: Mon, 25 Jul 2016 18:25:28 +0200 Subject: Imported Upstream version 2.0.2 --- darwin/DarwinProcess.c | 9 +++++++++ darwin/DarwinProcess.h | 1 + darwin/Platform.c | 8 +++----- 3 files changed, 13 insertions(+), 5 deletions(-) (limited to 'darwin') diff --git a/darwin/DarwinProcess.c b/darwin/DarwinProcess.c index 2bc6744..e1a16f9 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; } diff --git a/darwin/DarwinProcess.h b/darwin/DarwinProcess.h index df1a79f..c2058e2 100644 --- a/darwin/DarwinProcess.h +++ b/darwin/DarwinProcess.h @@ -19,6 +19,7 @@ typedef struct DarwinProcess_ { uint64_t utime; uint64_t stime; + bool taskAccess; } DarwinProcess; diff --git a/darwin/Platform.c b/darwin/Platform.c index 303b6c1..9274d0d 100644 --- a/darwin/Platform.c +++ b/darwin/Platform.c @@ -280,11 +280,9 @@ char* Platform_getProcessEnv(pid_t pid) { size_t size = endp - p; env = xMalloc(size+2); - if (env) { - memcpy(env, p, size); - env[size] = 0; - env[size+1] = 0; - } + memcpy(env, p, size); + env[size] = 0; + env[size+1] = 0; } } free(buf); -- cgit v1.2.3