Skip to content

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

glebm
Copy link

@glebm glebm commented Apr 27, 2025

2 changes to make htop compatible with OSX 10.4 Tiger

  1. mach_host_self() and vm_page_size are defined in mach_init.h.
  2. <libproc.h> API is not available, related functionality is disabled.

htop builds and works but cannot display per-process CPU% and task%. This can hopefully be improved in the future but at least it builds for now.

image

/cc @barracuda156

2 changes to make htop compatible with OSX 10.4 Tiger

1. `mach_host_self()` and `vm_page_size` are defined in `mach_init.h`.
2. `<libproc.h>` API is not available, related functionality is
   disabled.

htop builds and works but cannot display per-process CPU% and task%.
This can hopefully be improved in the future but at least it builds
for now.
@barracuda156
Copy link
Contributor

barracuda156 commented Apr 27, 2025

@glebm We have a breakage outside of Tiger, at least up to 10.6: #1686 (update: up to 10.10, as it follows from Apple docs).

(It is not seen on Tiger, of course, once you just disable the whole of related code, but a proper fix should be more nuanced.)

@BenBE BenBE added code quality ♻️ Code quality enhancement build system 🔧 Affects the build system rather then the user experience MacOS 🍏 MacOS / Darwin related issues labels Apr 27, 2025
@BenBE
Copy link
Member

BenBE commented Apr 27, 2025

Disabling huge chunks of the existing code may have very adverse effects. Please refine this patch in a way that it works more localized.

@glebm
Copy link
Author

glebm commented Apr 27, 2025

I have no idea how to make it more localized, considering that the entire <libproc.h> API is missing on 10.4.

Copy link
Member

@BenBE BenBE left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's what I mean by "too broad" …

Comment on lines +113 to +121
#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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This leaves Process_updateExe uninitialized; at least call this explicitly as NULL, so things can be set up correctly as "unavailable".

Comment on lines 141 to +142
free_and_xStrdup(&proc->procCwd, vpi.pvi_cdir.vip_path);
#endif
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here. at least call free_and_xStrdup(&proc->procCwd, NULL); so things are defined.

Comment on lines +411 to +413
#else
proc->taskAccess = false;
#endif
Copy link
Member

Choose a reason for hiding this comment

The 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.

@@ -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
Copy link
Member

Choose a reason for hiding this comment

The 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 …

@@ -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>
Copy link
Member

Choose a reason for hiding this comment

The 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?

Comment on lines +11 to +13
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
#include <libproc.h>
#endif
Copy link
Contributor

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.

@glebm
Copy link
Author

glebm commented Apr 27, 2025

Thank you for the review, I'll get back to it next weekend. In the meantime, I figured out how to get some of the info on Tiger (though it requires root for privileged processes).

@BenBE
Copy link
Member

BenBE commented Apr 27, 2025

Thank you for the review, I'll get back to it next weekend.
Take the time you need. With #1688 at least the immediate breakage from 10.6 onward should be taken care of.

In the meantime, I figured out how to get some of the info on Tiger (though it requires root for privileged processes).
This sound good to hear. If information are unavailable for some processes, this usually is not a problem. Some columns include some marker for "N/A" data that should be used in these cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build system 🔧 Affects the build system rather then the user experience code quality ♻️ Code quality enhancement MacOS 🍏 MacOS / Darwin related issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants