-
-
Notifications
You must be signed in to change notification settings - Fork 524
macOS: OSX 10.4 Tiger compatibility #1687
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,10 +7,15 @@ in the source distribution for its full text. | |
|
||
#include "darwin/DarwinProcess.h" | ||
|
||
#include <AvailabilityMacros.h> | ||
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050 | ||
#include <libproc.h> | ||
#endif | ||
|
||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
#include <mach/mach_init.h> | ||
#include <mach/mach.h> | ||
#include <sys/dirent.h> | ||
|
||
|
@@ -105,16 +110,19 @@ static int DarwinProcess_compareByKey(const Process* v1, const Process* v2, Proc | |
} | ||
|
||
static void DarwinProcess_updateExe(pid_t pid, Process* proc) { | ||
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050 | ||
char path[PROC_PIDPATHINFO_MAXSIZE]; | ||
|
||
int r = proc_pidpath(pid, path, sizeof(path)); | ||
if (r <= 0) | ||
return; | ||
|
||
Process_updateExe(proc, path); | ||
#endif | ||
Comment on lines
+113
to
+121
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This leaves |
||
} | ||
|
||
static void DarwinProcess_updateCwd(pid_t pid, Process* proc) { | ||
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050 | ||
struct proc_vnodepathinfo vpi; | ||
|
||
int r = proc_pidinfo(pid, PROC_PIDVNODEPATHINFO, 0, &vpi, sizeof(vpi)); | ||
|
@@ -131,6 +139,7 @@ static void DarwinProcess_updateCwd(pid_t pid, Process* proc) { | |
} | ||
|
||
free_and_xStrdup(&proc->procCwd, vpi.pvi_cdir.vip_path); | ||
#endif | ||
Comment on lines
141
to
+142
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here. at least call |
||
} | ||
|
||
static void DarwinProcess_updateCmdLine(const struct kinfo_proc* k, Process* proc) { | ||
|
@@ -360,6 +369,7 @@ void DarwinProcess_setFromKInfoProc(Process* proc, const struct kinfo_proc* ps, | |
} | ||
|
||
void DarwinProcess_setFromLibprocPidinfo(DarwinProcess* proc, DarwinProcessTable* dpt, double timeIntervalNS) { | ||
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050 | ||
struct proc_taskinfo pti; | ||
|
||
if (PROC_PIDTASKINFO_SIZE != proc_pidinfo(Process_getPid(&proc->super), PROC_PIDTASKINFO, 0, &pti, PROC_PIDTASKINFO_SIZE)) { | ||
|
@@ -398,6 +408,9 @@ void DarwinProcess_setFromLibprocPidinfo(DarwinProcess* proc, DarwinProcessTable | |
dpt->super.userlandThreads += pti.pti_threadnum; /*pti.pti_threads_user;*/ | ||
dpt->super.totalTasks += pti.pti_threadnum; | ||
dpt->super.runningTasks += pti.pti_numrunning; | ||
#else | ||
proc->taskAccess = false; | ||
#endif | ||
Comment on lines
+411
to
+413
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Try to fill all the other fields here too; and be it with sensible "defaults" like "no time passed" for "one task"/"none running". Mark a todo to implement these with older APIs as necessary. |
||
} | ||
|
||
/* | ||
|
@@ -406,6 +419,7 @@ void DarwinProcess_setFromLibprocPidinfo(DarwinProcess* proc, DarwinProcessTable | |
* and https://github.com/max-horvath/htop-osx/blob/e86692e869e30b0bc7264b3675d2a4014866ef46/ProcessList.c | ||
*/ | ||
void DarwinProcess_scanThreads(DarwinProcess* dp, DarwinProcessTable* dpt) { | ||
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050 | ||
Process* proc = (Process*) dp; | ||
kern_return_t ret; | ||
|
||
|
@@ -510,6 +524,7 @@ void DarwinProcess_scanThreads(DarwinProcess* dp, DarwinProcessTable* dpt) { | |
|
||
vm_deallocate(mach_task_self(), (vm_address_t) thread_list, sizeof(thread_port_array_t) * thread_count); | ||
mach_port_deallocate(mach_task_self(), task); | ||
#endif | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here. If there's not even essential information filled in we can also just declare things fully incompatible with such old versions of MacOS … |
||
} | ||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ in the source distribution for its full text. | |
#include <net/if_types.h> | ||
#include <net/route.h> | ||
#include <sys/socket.h> | ||
#include <mach/mach_init.h> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this here, when it's not used through new code? Or is was this missing before; and by which code? |
||
#include <mach/port.h> | ||
|
||
#include <CoreFoundation/CFBase.h> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See docs/styleguide.md. Conditional includes should be below headers that are always included.