aboutsummaryrefslogtreecommitdiffstats
path: root/solaris
diff options
context:
space:
mode:
authorDaniel Lange <DLange@git.local>2022-06-03 08:55:20 +0200
committerDaniel Lange <DLange@git.local>2022-06-03 08:55:20 +0200
commit937052b231259a47d881d539ad5748245ef55b99 (patch)
tree41071229fa007d8cf6902bb9253d2acd8cc66979 /solaris
parent1b805a31720727008b32b1129a167758519fd4db (diff)
downloaddebian_htop-937052b231259a47d881d539ad5748245ef55b99.tar.gz
debian_htop-937052b231259a47d881d539ad5748245ef55b99.tar.bz2
debian_htop-937052b231259a47d881d539ad5748245ef55b99.zip
New upstream version 3.2.1upstream/3.2.1
Diffstat (limited to 'solaris')
-rw-r--r--solaris/Platform.c22
-rw-r--r--solaris/SolarisProcess.c2
-rw-r--r--solaris/SolarisProcessList.c4
3 files changed, 17 insertions, 11 deletions
diff --git a/solaris/Platform.c b/solaris/Platform.c
index 20b4d13..9c5acb5 100644
--- a/solaris/Platform.c
+++ b/solaris/Platform.c
@@ -267,16 +267,21 @@ static int Platform_buildenv(void* accum, struct ps_prochandle* Phandle, uintptr
envAccum* accump = accum;
(void) Phandle;
(void) addr;
+
size_t thissz = strlen(str);
- if ((thissz + 2) > (accump->capacity - accump->size)) {
- accump->env = xRealloc(accump->env, accump->capacity *= 2);
- }
- if ((thissz + 2) > (accump->capacity - accump->size)) {
- return 1;
+
+ while ((thissz + 2) > (accump->capacity - accump->size)) {
+ if (accump->capacity > (SIZE_MAX / 2))
+ return 1;
+
+ accump->capacity *= 2;
+ accump->env = xRealloc(accump->env, accump->capacity);
}
- strlcpy( accump->env + accump->size, str, (accump->capacity - accump->size));
+
+ strlcpy( accump->env + accump->size, str, accump->capacity - accump->size);
strncpy( accump->env + accump->size + thissz + 1, "\n", 2);
- accump->size = accump->size + thissz + 1;
+
+ accump->size += thissz + 1;
return 0;
}
@@ -299,7 +304,8 @@ char* Platform_getProcessEnv(pid_t pid) {
Prelease(Phandle, 0);
strncpy( envBuilder.env + envBuilder.size, "\0", 1);
- return envBuilder.env;
+
+ return xRealloc(envBuilder.env, envBuilder.size + 1);
}
char* Platform_getInodeFilename(pid_t pid, ino_t inode) {
diff --git a/solaris/SolarisProcess.c b/solaris/SolarisProcess.c
index ae8bd70..840757e 100644
--- a/solaris/SolarisProcess.c
+++ b/solaris/SolarisProcess.c
@@ -40,7 +40,7 @@ const ProcessFieldData Process_fields[LAST_PROCESSFIELD] = {
[M_VIRT] = { .name = "M_VIRT", .title = " VIRT ", .description = "Total program size in virtual memory", .flags = 0, .defaultSortDesc = true, },
[M_RESIDENT] = { .name = "M_RESIDENT", .title = " RES ", .description = "Resident set size, size of the text and data sections, plus stack usage", .flags = 0, .defaultSortDesc = true, },
[ST_UID] = { .name = "ST_UID", .title = "UID", .description = "User ID of the process owner", .flags = 0, },
- [PERCENT_CPU] = { .name = "PERCENT_CPU", .title = "CPU% ", .description = "Percentage of the CPU time the process used in the last sampling", .flags = 0, .defaultSortDesc = true, .autoWidth = true, },
+ [PERCENT_CPU] = { .name = "PERCENT_CPU", .title = " CPU%", .description = "Percentage of the CPU time the process used in the last sampling", .flags = 0, .defaultSortDesc = true, .autoWidth = true, },
[PERCENT_NORM_CPU] = { .name = "PERCENT_NORM_CPU", .title = "NCPU%", .description = "Normalized percentage of the CPU time the process used in the last sampling (normalized by cpu count)", .flags = 0, .defaultSortDesc = true, .autoWidth = true, },
[PERCENT_MEM] = { .name = "PERCENT_MEM", .title = "MEM% ", .description = "Percentage of the memory the process is using, based on resident memory size", .flags = 0, .defaultSortDesc = true, },
[USER] = { .name = "USER", .title = "USER ", .description = "Username of the process owner (or user ID if name cannot be determined)", .flags = 0, },
diff --git a/solaris/SolarisProcessList.c b/solaris/SolarisProcessList.c
index 0c619ae..905cfbd 100644
--- a/solaris/SolarisProcessList.c
+++ b/solaris/SolarisProcessList.c
@@ -468,7 +468,7 @@ static int SolarisProcessList_walkproc(psinfo_t* _psinfo, lwpsinfo_t* _lwpsinfo,
proc->percent_cpu = ((uint16_t)_psinfo->pr_pctcpu / (double)32768) * (double)100.0;
Process_updateCPUFieldWidths(proc->percent_cpu);
- proc->time = _psinfo->pr_time.tv_sec;
+ proc->time = _psinfo->pr_time.tv_sec * 100 + _psinfo->pr_time.tv_nsec / 10000000;
if (!preExisting) { // Tasks done only for NEW processes
proc->isUserlandThread = false;
proc->starttime_ctime = _psinfo->pr_start.tv_sec;
@@ -497,7 +497,7 @@ static int SolarisProcessList_walkproc(psinfo_t* _psinfo, lwpsinfo_t* _lwpsinfo,
proc->percent_cpu = ((uint16_t)_lwpsinfo->pr_pctcpu / (double)32768) * (double)100.0;
Process_updateCPUFieldWidths(proc->percent_cpu);
- proc->time = _lwpsinfo->pr_time.tv_sec;
+ proc->time = _lwpsinfo->pr_time.tv_sec * 100 + _lwpsinfo->pr_time.tv_nsec / 10000000;
if (!preExisting) { // Tasks done only for NEW LWPs
proc->isUserlandThread = true;
proc->ppid = _psinfo->pr_pid * 1024;

© 2014-2024 Faster IT GmbH | imprint | privacy policy