This commit is contained in:
Hisham Muhammad 2016-01-03 16:32:48 -02:00
commit be9edc5d43
7 changed files with 42 additions and 33 deletions

View File

@ -28,7 +28,7 @@ void CRT_handleSIGSEGV(int sgn) {
#endif #endif
#else #else
fprintf(stderr, "\nUnfortunately, you seem to be using an unsupported platform!"); 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 #endif
abort(); abort();
} }

View File

@ -15,7 +15,7 @@ void CRT_handleSIGSEGV(int sgn) {
CRT_done(); CRT_done();
fprintf(stderr, "\n\nhtop " VERSION " aborting.\n"); fprintf(stderr, "\n\nhtop " VERSION " aborting.\n");
fprintf(stderr, "\nUnfortunately, you seem to be using an unsupported platform!"); 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(); abort();
} }

View File

@ -30,7 +30,7 @@ void CRT_handleSIGSEGV(int sgn) {
#endif #endif
#else #else
fprintf(stderr, "\nUnfortunately, you seem to be using an unsupported platform!"); 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 #endif
abort(); abort();
} }

View File

@ -16,7 +16,7 @@ void CRT_handleSIGSEGV(int sgn) {
CRT_done(); CRT_done();
fprintf(stderr, "\n\nhtop " VERSION " aborting.\n"); fprintf(stderr, "\n\nhtop " VERSION " aborting.\n");
fprintf(stderr, "\nUnfortunately, you seem to be using an unsupported platform!"); 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(); abort();
} }

View File

@ -12,6 +12,7 @@ in the source distribution for its full text.
#include <unistd.h> #include <unistd.h>
#include <stdlib.h> #include <stdlib.h>
#include <err.h>
#include <errno.h> #include <errno.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/param.h> #include <sys/param.h>
@ -59,7 +60,7 @@ ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList, ui
size = sizeof(fscale); size = sizeof(fscale);
if (sysctl(fmib, 2, &fscale, &size, NULL, 0) < 0) 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++) { for (i = 0; i < pl->cpuCount; i++) {
fpl->cpus[i].totalTime = 1; fpl->cpus[i].totalTime = 1;
@ -89,7 +90,7 @@ static inline void OpenBSDProcessList_scanMemoryInfo(ProcessList* pl) {
size_t size = sizeof(uvmexp); size_t size = sizeof(uvmexp);
if (sysctl(uvmexp_mib, 2, &uvmexp, &size, NULL, 0) < 0) { 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; //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 *OpenBSDProcessList_readProcessName(kvm_t* kd, struct kinfo_proc* kproc, int* basenameEnd) {
char *str, *buf, **argv; char *s, *buf, **arg;
size_t cpsz; size_t cpsz, len = 0, n;
size_t len = 500; int i;
argv = kvm_getargv(kd, kproc, 500); /*
* We attempt to fall back to just the command name (argv[0]) if we
if (argv == NULL) * fail to construct the full command at any point.
CRT_fatalError("kvm call failed"); */
arg = kvm_getargv(kd, kproc, 500);
str = buf = malloc(len+1); if (arg == NULL) {
if (str == NULL) if ((s = strdup(kproc->p_comm)) == NULL) {
CRT_fatalError("out of memory"); err(1, NULL);
}
while (*argv != NULL) { return s;
cpsz = MIN(len, strlen(*argv));
strncpy(buf, *argv, cpsz);
buf += cpsz;
len -= cpsz;
argv++;
if (len > 0) {
*buf = ' ';
buf++;
len--;
}
} }
for (i = 0; arg[i] != NULL; i++) {
*buf = '\0'; len += strlen(arg[i]) + 1;
return str; }
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;
} }
/* /*

View File

@ -11,6 +11,7 @@ in the source distribution for its full text.
*/ */
#include "Action.h" #include "Action.h"
#include "SignalsPanel.h"
#include "BatteryMeter.h" #include "BatteryMeter.h"
extern ProcessFieldData Process_fields[]; extern ProcessFieldData Process_fields[];

View File

@ -15,7 +15,7 @@ void CRT_handleSIGSEGV(int sgn) {
CRT_done(); CRT_done();
fprintf(stderr, "\n\nhtop " VERSION " aborting.\n"); fprintf(stderr, "\n\nhtop " VERSION " aborting.\n");
fprintf(stderr, "\nUnfortunately, you seem to be using an unsupported platform!"); 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(); abort();
} }