summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2016-01-03 16:32:48 -0200
committerHisham Muhammad <hisham@gobolinux.org>2016-01-03 16:32:48 -0200
commitbe9edc5d4302fc83281e6323bc1df72796c1b49c (patch)
treef7c34dea2dbe47c46b7d1d870986e73b99d97e88
parent70cd5c2b88ca6b2f9966a5e9b3e8be19a938b7f7 (diff)
parent86954f920481105568e23ab81617842d7ba4828b (diff)
Merge branch 'master' of https://github.com/hishamhm/htop
-rw-r--r--darwin/DarwinCRT.c2
-rw-r--r--freebsd/FreeBSDCRT.c2
-rw-r--r--linux/LinuxCRT.c2
-rw-r--r--openbsd/OpenBSDCRT.c2
-rw-r--r--openbsd/OpenBSDProcessList.c66
-rw-r--r--openbsd/Platform.h1
-rw-r--r--unsupported/UnsupportedCRT.c2
7 files changed, 43 insertions, 34 deletions
diff --git a/darwin/DarwinCRT.c b/darwin/DarwinCRT.c
index 3efb18a7..51725984 100644
--- a/darwin/DarwinCRT.c
+++ b/darwin/DarwinCRT.c
@@ -28,7 +28,7 @@ void CRT_handleSIGSEGV(int sgn) {
#endif
#else
fprintf(stderr, "\nUnfortunately, you seem to be using an unsupported platform!");
- fprintf(stderr, "\nPlease contact your platform package mantainer!\n\n");
+ fprintf(stderr, "\nPlease contact your platform package maintainer!\n\n");
#endif
abort();
}
diff --git a/freebsd/FreeBSDCRT.c b/freebsd/FreeBSDCRT.c
index c4e65eeb..5c3a9de4 100644
--- a/freebsd/FreeBSDCRT.c
+++ b/freebsd/FreeBSDCRT.c
@@ -15,7 +15,7 @@ void CRT_handleSIGSEGV(int sgn) {
CRT_done();
fprintf(stderr, "\n\nhtop " VERSION " aborting.\n");
fprintf(stderr, "\nUnfortunately, you seem to be using an unsupported platform!");
- fprintf(stderr, "\nPlease contact your platform package mantainer!\n\n");
+ fprintf(stderr, "\nPlease contact your platform package maintainer!\n\n");
abort();
}
diff --git a/linux/LinuxCRT.c b/linux/LinuxCRT.c
index e0a12821..5b2a21fd 100644
--- a/linux/LinuxCRT.c
+++ b/linux/LinuxCRT.c
@@ -30,7 +30,7 @@ void CRT_handleSIGSEGV(int sgn) {
#endif
#else
fprintf(stderr, "\nUnfortunately, you seem to be using an unsupported platform!");
- fprintf(stderr, "\nPlease contact your platform package mantainer!\n\n");
+ fprintf(stderr, "\nPlease contact your platform package maintainer!\n\n");
#endif
abort();
}
diff --git a/openbsd/OpenBSDCRT.c b/openbsd/OpenBSDCRT.c
index 552ca30d..c5dcec4a 100644
--- a/openbsd/OpenBSDCRT.c
+++ b/openbsd/OpenBSDCRT.c
@@ -16,7 +16,7 @@ void CRT_handleSIGSEGV(int sgn) {
CRT_done();
fprintf(stderr, "\n\nhtop " VERSION " aborting.\n");
fprintf(stderr, "\nUnfortunately, you seem to be using an unsupported platform!");
- fprintf(stderr, "\nPlease contact your platform package mantainer!\n\n");
+ fprintf(stderr, "\nPlease contact your platform package maintainer!\n\n");
abort();
}
diff --git a/openbsd/OpenBSDProcessList.c b/openbsd/OpenBSDProcessList.c
index 210328aa..25f63349 100644
--- a/openbsd/OpenBSDProcessList.c
+++ b/openbsd/OpenBSDProcessList.c
@@ -12,6 +12,7 @@ in the source distribution for its full text.
#include <unistd.h>
#include <stdlib.h>
+#include <err.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/param.h>
@@ -59,7 +60,7 @@ ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList, ui
size = sizeof(fscale);
if (sysctl(fmib, 2, &fscale, &size, NULL, 0) < 0)
- CRT_fatalError("fscale sysctl call failed");
+ err(1, "fscale sysctl call failed");
for (i = 0; i < pl->cpuCount; i++) {
fpl->cpus[i].totalTime = 1;
@@ -89,7 +90,7 @@ static inline void OpenBSDProcessList_scanMemoryInfo(ProcessList* pl) {
size_t size = sizeof(uvmexp);
if (sysctl(uvmexp_mib, 2, &uvmexp, &size, NULL, 0) < 0) {
- CRT_fatalError("uvmexp sysctl call failed");
+ err(1, "uvmexp sysctl call failed");
}
//kb_pagesize = uvmexp.pagesize / 1024;
@@ -125,34 +126,41 @@ static inline void OpenBSDProcessList_scanMemoryInfo(ProcessList* pl) {
}
char *OpenBSDProcessList_readProcessName(kvm_t* kd, struct kinfo_proc* kproc, int* basenameEnd) {
- char *str, *buf, **argv;
- size_t cpsz;
- size_t len = 500;
-
- argv = kvm_getargv(kd, kproc, 500);
-
- if (argv == NULL)
- CRT_fatalError("kvm call failed");
-
- str = buf = malloc(len+1);
- if (str == NULL)
- CRT_fatalError("out of memory");
-
- while (*argv != NULL) {
- cpsz = MIN(len, strlen(*argv));
- strncpy(buf, *argv, cpsz);
- buf += cpsz;
- len -= cpsz;
- argv++;
- if (len > 0) {
- *buf = ' ';
- buf++;
- len--;
- }
- }
+ char *s, *buf, **arg;
+ size_t cpsz, len = 0, n;
+ int i;
- *buf = '\0';
- return str;
+ /*
+ * We attempt to fall back to just the command name (argv[0]) if we
+ * fail to construct the full command at any point.
+ */
+ arg = kvm_getargv(kd, kproc, 500);
+ if (arg == NULL) {
+ if ((s = strdup(kproc->p_comm)) == NULL) {
+ err(1, NULL);
+ }
+ return s;
+ }
+ for (i = 0; arg[i] != NULL; i++) {
+ len += strlen(arg[i]) + 1;
+ }
+ if ((buf = s = malloc(len)) == NULL) {
+ if ((s = strdup(kproc->p_comm)) == NULL) {
+ err(1, NULL);
+ }
+ return s;
+ }
+ for (i = 0; arg[i] != NULL; i++) {
+ n = strlcpy(buf, arg[i], (s + len) - buf);
+ buf += n;
+ if (i == 0) {
+ *basenameEnd = n;
+ }
+ *buf = ' ';
+ buf++;
+ }
+ *(buf - 1) = '\0';
+ return s;
}
/*
diff --git a/openbsd/Platform.h b/openbsd/Platform.h
index a59d2ef5..d8dea1b1 100644
--- a/openbsd/Platform.h
+++ b/openbsd/Platform.h
@@ -11,6 +11,7 @@ in the source distribution for its full text.
*/
#include "Action.h"
+#include "SignalsPanel.h"
#include "BatteryMeter.h"
extern ProcessFieldData Process_fields[];
diff --git a/unsupported/UnsupportedCRT.c b/unsupported/UnsupportedCRT.c
index c4e65eeb..5c3a9de4 100644
--- a/unsupported/UnsupportedCRT.c
+++ b/unsupported/UnsupportedCRT.c
@@ -15,7 +15,7 @@ void CRT_handleSIGSEGV(int sgn) {
CRT_done();
fprintf(stderr, "\n\nhtop " VERSION " aborting.\n");
fprintf(stderr, "\nUnfortunately, you seem to be using an unsupported platform!");
- fprintf(stderr, "\nPlease contact your platform package mantainer!\n\n");
+ fprintf(stderr, "\nPlease contact your platform package maintainer!\n\n");
abort();
}