htop
htop copied to clipboard
new: Added support for "truss" (FreeBSD equivalent of "strace")
The patch is for FreeBSD, but I'm quite certain "truss" will be present in the base systems of NetBSD, OpenBSD and DragonflyBSD. It's confirmed to work only on FreeBSD.
That should do it :) Confirmed that it works on my build system. Thanks
Is it possible to check for truss
at the configure time? I think it's bet not to assume the program is available unless htop is built to be a "cross" (--host
machine different from --target
machine). Same goes for strace
, too.
Sure, whatever works @Explorer09. I don't know how m4/autoconf stuff works under the hood. So I prepared a quick patch to get the things done. I agree that htop should detect that strace exists only in Linux from the start.
@Explorer09: I'm indifferent about the exact implementation, be it configure or compile time, as long as it properly covers all platforms …
@BenBE I don't know what platform "PCP" is… so I just assumed it's unsupported. Now the platform list is exhaustive.
I don't know what platform "PCP" is…
It's the code below pcp/ in the git repo and the --enable-pcp configure option (https://pcp.io) that produces pcp-htop. It's fine to not include tracing functionality for this platform.
truss(1) on Solaris didn't support -s <strsize>
, instead it has a completely different option with same name:
-s [!]<signal>[,...]
Therefore -s 512
must be removed in case of Solaris.
Two more things needed (besides the Solaris split):
- Mention truss in
htop.1.in
(man file) -
#ifdef
help screen (Action.c
) to change strace -> truss on the affected platforms
I'm quite certain "truss" will be present in the base systems of NetBSD, OpenBSD and DragonflyBSD.
On NetBSD the command is ktruss. It is quite easy to check the manual pages of other BSDs on man.freebsd.org.
@dmilith Can you please update this PR to resolve the merge conflicts?
Hey. It looks like issue #644 can be addressed together with this PR.
On MacOS there's dtruss
, but tests have shown, that it's far to broken to be usable.
If you are eager to tests:
$ git diff
diff --git a/TraceScreen.c b/TraceScreen.c
index 8232418d..f88a34b2 100644
--- a/TraceScreen.c
+++ b/TraceScreen.c
@@ -96,13 +96,18 @@ bool TraceScreen_forkTracer(TraceScreen* this) {
const char* message = "Could not execute 'truss'. Please make sure it is available in your $PATH.";
(void)! write(STDERR_FILENO, message, strlen(message));
+ #if defined(HTOP_DARWIN)
+ execlp("dtruss", "dtruss", "-a", "-p", buffer, NULL);
+
+ const char* message = "Could not execute 'dtruss'. Please make sure it is available in your $PATH.";
+ (void)! write(STDERR_FILENO, message, strlen(message));
#elif defined(HTOP_LINUX)
execlp("strace", "strace", "-T", "-tt", "-s", "512", "-p", buffer, NULL);
// Should never reach here, unless execlp fails ...
const char* message = "Could not execute 'strace'. Please make sure it is available in your $PATH.";
(void)! write(STDERR_FILENO, message, strlen(message));
- #else // HTOP_DARWIN, HTOP_PCP == HTOP_UNSUPPORTED
+ #else // HTOP_PCP == HTOP_UNSUPPORTED
const char* message = "Tracing unavailable on not supported system.";
(void)! write(STDERR_FILENO, message, strlen(message));
#endif
Beware, it will likely hang your system in different way …
Not applying support for MacOS.
Superseeded by #1357