Htop: Feature request: try use dtruss if strace is unavailable

Created on 27 Sep 2017  路  8Comments  路  Source: hishamhm/htop

Currently, it is not possible to trace system calls from htop if straceis unavailable.
As strace is not available on all platforms (_eg_ macOS), it would be nice to fallback to dtruss if strace is not in $PATH.

feature request macOS

Most helpful comment

@hishamhm I would also appreciate this feature. Not everyone runs with SIP enabled and if you do, then you should expect issues when trying to do something like tracing processes. Running with SIP as a developer on macOS is like putting training wheels on a motorcycle, IMO. In other words, no developer who intends to use his system realistically does it.

Currently, the code in TraceScreen.c does not try to run dtruss at all and it uses arguments which are incompatible with dtruss. Would you accept a patch to fix this?

All 8 comments

Right - should $PATH-check if dtruss can be found in that case (and perhaps also a check for mac-speciic platforms ... but $PATH checking may be enough I guess).

Is dtruss installed by default on Macs?

@hishamhm I believe you need to install developer tools. For anyone using htop on a Mac, it seems like a reasonable dependency.

It seems however that the "System Integrity Protection" introduced with macOS 10.11 prevents dtruss to attach processes from unsigned executables.

For example, a simple sudo dtruss ls . on macOS 10.13 outputs:

dtrace: system integrity protection is on, some features will not be available
dtrace: failed to execute ls: dtrace cannot control executables signed with restricted entitlements

Signed executables can be attached (like sudo dtruss -n "Mail"), but the system protection still prevents dtruss to catch some system calls. This generates some outputs in the standard error.

Thank you all for the feedback! It seems that, due to system restrictions, the usability of the feature would be greatly reduced, unfortunately. I'm keeping t

I'll keep this filed in the feature requests label, as the issues tracker keeps open bugs only. More info here! Thanks for understanding!

While SIP would block tracing of signed binaries in standard locations (such as /usr/bin), this restriction doesn't apply to binaries in other locations. This makes dtruss very useful for any binary that's locally installed.

Since strace fails anyway, I'd very much appreciate a feature that at least would try to run dtruss instead. That may fail too, but since it also could succeed that'd be a win over the current situation.

@hishamhm I would also appreciate this feature. Not everyone runs with SIP enabled and if you do, then you should expect issues when trying to do something like tracing processes. Running with SIP as a developer on macOS is like putting training wheels on a motorcycle, IMO. In other words, no developer who intends to use his system realistically does it.

Currently, the code in TraceScreen.c does not try to run dtruss at all and it uses arguments which are incompatible with dtruss. Would you accept a patch to fix this?

I propose reopening this issue. It would be a great feature for macOS users.

Was this page helpful?
0 / 5 - 0 ratings