summaryrefslogtreecommitdiffstats
path: root/ksysguard/ksysguardd/FreeBSD/ProcessList.c
diff options
context:
space:
mode:
authorDaniel Collins <solemnwarning@solemnwarning.net>2023-05-27 17:39:13 +0100
committerDaniel Collins <solemnwarning@solemnwarning.net>2023-05-29 23:12:40 +0100
commitf885561fda56d3b6eb47b1979a547b49a00954a2 (patch)
tree7dd89f473a71a7809c0d197c258d76dd4467d856 /ksysguard/ksysguardd/FreeBSD/ProcessList.c
parent31335a04ed9bc01fd3ede33afde40d6f3359f2e9 (diff)
downloadtdebase-f885561fda56d3b6eb47b1979a547b49a00954a2.tar.gz
tdebase-f885561fda56d3b6eb47b1979a547b49a00954a2.zip
[ksysguardd] Use size_t for storing process memory usage.
Avoids the process memory usage rolling over at 4GiB on 64-bit systems. Signed-off-by: Daniel Collins <solemnwarning@solemnwarning.net>
Diffstat (limited to 'ksysguard/ksysguardd/FreeBSD/ProcessList.c')
-rw-r--r--ksysguard/ksysguardd/FreeBSD/ProcessList.c18
1 files changed, 6 insertions, 12 deletions
diff --git a/ksysguard/ksysguardd/FreeBSD/ProcessList.c b/ksysguard/ksysguardd/FreeBSD/ProcessList.c
index f8d2c3ba6..dbb330efb 100644
--- a/ksysguard/ksysguardd/FreeBSD/ProcessList.c
+++ b/ksysguard/ksysguardd/FreeBSD/ProcessList.c
@@ -98,18 +98,12 @@ typedef struct
* The total amount of memory the process uses. This includes shared and
* swapped memory.
*/
- unsigned int vmSize;
+ size_t vmSize;
/*
* The amount of physical memory the process currently uses.
*/
- unsigned int vmRss;
-
- /*
- * The amount of memory (shared/swapped/etc) the process shares with
- * other processes.
- */
- unsigned int vmLib;
+ size_t vmRss;
/*
* The number of 1/100 of a second the process has spend in user space.
@@ -264,20 +258,20 @@ updateProcess(int pid)
#if __FreeBSD_version >= 500015
ps->userLoad = 100.0 * (double) p.ki_pctcpu / fscale;
ps->vmSize = p.ki_size;
- ps->vmRss = p.ki_rssize * getpagesize();
+ ps->vmRss = (size_t)(p.ki_rssize) * (size_t)(getpagesize());
strlcpy(ps->name,p.ki_comm? p.ki_comm:"????",sizeof(ps->name));
strcpy(ps->status,(p.ki_stat>=1)&&(p.ki_stat<=5)? statuses[p.ki_stat-1]:"????");
#elif defined (__DragonFly__) && __DragonFly_version >= 190000
ps->userLoad = 100.0 * (double) p.kp_lwp.kl_pctcpu / fscale;
ps->vmSize = p.kp_vm_map_size;
- ps->vmRss = p.kp_vm_rssize * getpagesize();
+ ps->vmRss = (size_t)(p.kp_vm_rssize) * (size_t)(getpagesize());
strlcpy(ps->name,p.kp_comm ? p.kp_comm : "????",
sizeof(ps->name));
strcpy(ps->status,(p.kp_stat>=1)&&(p.kp_stat<=5)? statuses[p.kp_stat-1]:"????");
#else
ps->userLoad = 100.0 * (double) p.kp_proc.p_pctcpu / fscale;
ps->vmSize = p.kp_eproc.e_vm.vm_map.size;
- ps->vmRss = p.kp_eproc.e_vm.vm_rssize * getpagesize();
+ ps->vmRss = (size_t)(p.kp_eproc.e_vm.vm_rssize) * (size_t)(getpagesize());
#if defined (__DragonFly__)
strlcpy(ps->name,p.kp_thread.td_comm ? p.kp_thread.td_comm : "????",
sizeof(ps->name));
@@ -417,7 +411,7 @@ printProcessList(const char* cmd)
ps = first_ctnr(ProcessList); /* skip 'kernel' entry */
for (ps = next_ctnr(ProcessList); ps; ps = next_ctnr(ProcessList))
{
- fprintf(CurrentClient, "%s\t%ld\t%ld\t%ld\t%ld\t%s\t%.2f\t%.2f\t%d\t%d\t%d\t%s\t%s\n",
+ fprintf(CurrentClient, "%s\t%ld\t%ld\t%ld\t%ld\t%s\t%.2f\t%.2f\t%d\t%zu\t%zu\t%s\t%s\n",
ps->name, (long)ps->pid, (long)ps->ppid,
(long)ps->uid, (long)ps->gid, ps->status,
ps->userLoad, ps->sysLoad, ps->niceLevel,