lcdproc client: Fix core dumps on FreeBSD if started as non-root.

This commit is contained in:
mmdolze
2011-11-20 16:35:42 +00:00
parent 2a5bf194df
commit 85241c253d
4 changed files with 28 additions and 11 deletions
+3
View File
@@ -7,6 +7,9 @@ V0.5dev:
a non full block from the vBar. Affected drivers: IOWarrior, CwLinux
- On Solaris the mtc_s16209x driver fails to compile. Configure LCDproc to
exclude this driver.
- The lcdproc client currently ignores errors from the machine dependent
functions. This may result in strange behaviour of the screens or core
dumps.
Bugs in previous versions (not checked if the still exist):
+1
View File
@@ -16,6 +16,7 @@ v0.5dev (ongoing development)
+ hd44780: Fix vBars and block icon not working correctly on the same screen
* Build system: Link LCDd itself with pthread library if available
* lcdproc client: Unbreak build on OpenBSD non-i386 (E. Barrett)
* lcdproc client: Fix core dumps on FreeBSD if started as non-root
v0.5.5
+ sed1330 driver: Add support for HG25504 (L. Lagendijk)
+18 -10
View File
@@ -106,7 +106,10 @@ machine_init(void)
int
machine_close(void)
{
kvm_close(kvmd);
if (kvmd != NULL) {
kvm_close(kvmd);
kvmd = NULL;
}
return (TRUE);
}
@@ -311,10 +314,12 @@ machine_get_procs(LinkedList * procs)
int nproc, i;
procinfo_type *p;
if (kvmd == NULL)
return (FALSE);
kprocs = kvm_getprocs(kvmd, KERN_PROC_ALL, 0, &nproc);
if (kprocs == NULL) {
perror("kvm_getprocs");
kvm_close(kvmd);
return (FALSE);
}
@@ -322,7 +327,6 @@ machine_get_procs(LinkedList * procs)
p = malloc(sizeof(procinfo_type));
if (!p) {
perror("mem_top_malloc");
kvm_close(kvmd);
return (FALSE);
}
#if (__FreeBSD_version > 500000)
@@ -355,6 +359,9 @@ machine_get_smpload(load_type * result, int *numcpus)
#ifdef HAVE_SYS_PCPU_H
static load_type last_load[MAX_CPUS];
struct pcpu *pcpudata;
if (kvmd == NULL)
return (FALSE);
#endif
if (numcpus == NULL)
@@ -439,20 +446,23 @@ machine_get_uptime(double *up, double *idle)
return (TRUE);
}
/**
* Reads info about swap space from system and returns it in parameters passed.
* \param retavail Total available swap space
* \param retfree Free swap space
* \return -1 on error, otherwise number of swap areas (typically 0 for total)
*/
static int
swapmode(int *retavail, int *retfree)
{
int n;
struct kvm_swap swapary[1];
kvm_t *kvmd;
*retavail = 0;
*retfree = 0;
if ((kvmd = kvm_open(NULL, NULL, NULL, O_RDONLY, "kvm_open")) == NULL) {
perror("read kvm");
return (-1);
}
if (kvmd == NULL)
return -1;
n = kvm_getswapinfo(kvmd, swapary, 1, 0);
if (n < 0 || swapary[0].ksw_total == 0) {
@@ -463,8 +473,6 @@ swapmode(int *retavail, int *retfree)
*retfree = pagetok(swapary[0].ksw_total - swapary[0].ksw_used);
}
kvm_close(kvmd);
return (n);
}
+6 -1
View File
@@ -288,6 +288,7 @@ mem_top_screen(int rep, int display, int *flags_ptr)
sock_send_string(sock, "widget_set S 1 1 1 Checking...\n");
}
/* Create a new process list */
procs = LL_new();
if (procs == NULL) {
fprintf(stderr, "mem_top_screen: Error allocating list\n");
@@ -295,6 +296,10 @@ mem_top_screen(int rep, int display, int *flags_ptr)
}
machine_get_procs(procs);
/*
* Ignore if machine_get_procs returns an errror. The list will be
* empty then and all process info will be shown empty, too.
*/
/* Now, print some info... */
LL_Rewind(procs);
@@ -325,7 +330,7 @@ mem_top_screen(int rep, int display, int *flags_ptr)
LL_Next(procs);
}
/* Now clean it all up... */
/* Delete the process list */
LL_Rewind(procs);
do {
procinfo_type *p = (procinfo_type *) LL_Get(procs);