lcdproc client: Fix core dumps on FreeBSD if started as non-root.
This commit is contained in:
@@ -7,6 +7,9 @@ V0.5dev:
|
|||||||
a non full block from the vBar. Affected drivers: IOWarrior, CwLinux
|
a non full block from the vBar. Affected drivers: IOWarrior, CwLinux
|
||||||
- On Solaris the mtc_s16209x driver fails to compile. Configure LCDproc to
|
- On Solaris the mtc_s16209x driver fails to compile. Configure LCDproc to
|
||||||
exclude this driver.
|
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):
|
Bugs in previous versions (not checked if the still exist):
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ v0.5dev (ongoing development)
|
|||||||
+ hd44780: Fix vBars and block icon not working correctly on the same screen
|
+ hd44780: Fix vBars and block icon not working correctly on the same screen
|
||||||
* Build system: Link LCDd itself with pthread library if available
|
* Build system: Link LCDd itself with pthread library if available
|
||||||
* lcdproc client: Unbreak build on OpenBSD non-i386 (E. Barrett)
|
* 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
|
v0.5.5
|
||||||
+ sed1330 driver: Add support for HG25504 (L. Lagendijk)
|
+ sed1330 driver: Add support for HG25504 (L. Lagendijk)
|
||||||
|
|||||||
@@ -106,7 +106,10 @@ machine_init(void)
|
|||||||
int
|
int
|
||||||
machine_close(void)
|
machine_close(void)
|
||||||
{
|
{
|
||||||
kvm_close(kvmd);
|
if (kvmd != NULL) {
|
||||||
|
kvm_close(kvmd);
|
||||||
|
kvmd = NULL;
|
||||||
|
}
|
||||||
return (TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -311,10 +314,12 @@ machine_get_procs(LinkedList * procs)
|
|||||||
int nproc, i;
|
int nproc, i;
|
||||||
procinfo_type *p;
|
procinfo_type *p;
|
||||||
|
|
||||||
|
if (kvmd == NULL)
|
||||||
|
return (FALSE);
|
||||||
|
|
||||||
kprocs = kvm_getprocs(kvmd, KERN_PROC_ALL, 0, &nproc);
|
kprocs = kvm_getprocs(kvmd, KERN_PROC_ALL, 0, &nproc);
|
||||||
if (kprocs == NULL) {
|
if (kprocs == NULL) {
|
||||||
perror("kvm_getprocs");
|
perror("kvm_getprocs");
|
||||||
kvm_close(kvmd);
|
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -322,7 +327,6 @@ machine_get_procs(LinkedList * procs)
|
|||||||
p = malloc(sizeof(procinfo_type));
|
p = malloc(sizeof(procinfo_type));
|
||||||
if (!p) {
|
if (!p) {
|
||||||
perror("mem_top_malloc");
|
perror("mem_top_malloc");
|
||||||
kvm_close(kvmd);
|
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
#if (__FreeBSD_version > 500000)
|
#if (__FreeBSD_version > 500000)
|
||||||
@@ -355,6 +359,9 @@ machine_get_smpload(load_type * result, int *numcpus)
|
|||||||
#ifdef HAVE_SYS_PCPU_H
|
#ifdef HAVE_SYS_PCPU_H
|
||||||
static load_type last_load[MAX_CPUS];
|
static load_type last_load[MAX_CPUS];
|
||||||
struct pcpu *pcpudata;
|
struct pcpu *pcpudata;
|
||||||
|
|
||||||
|
if (kvmd == NULL)
|
||||||
|
return (FALSE);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (numcpus == NULL)
|
if (numcpus == NULL)
|
||||||
@@ -439,20 +446,23 @@ machine_get_uptime(double *up, double *idle)
|
|||||||
return (TRUE);
|
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
|
static int
|
||||||
swapmode(int *retavail, int *retfree)
|
swapmode(int *retavail, int *retfree)
|
||||||
{
|
{
|
||||||
int n;
|
int n;
|
||||||
struct kvm_swap swapary[1];
|
struct kvm_swap swapary[1];
|
||||||
kvm_t *kvmd;
|
|
||||||
|
|
||||||
*retavail = 0;
|
*retavail = 0;
|
||||||
*retfree = 0;
|
*retfree = 0;
|
||||||
|
|
||||||
if ((kvmd = kvm_open(NULL, NULL, NULL, O_RDONLY, "kvm_open")) == NULL) {
|
if (kvmd == NULL)
|
||||||
perror("read kvm");
|
return -1;
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
n = kvm_getswapinfo(kvmd, swapary, 1, 0);
|
n = kvm_getswapinfo(kvmd, swapary, 1, 0);
|
||||||
if (n < 0 || swapary[0].ksw_total == 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);
|
*retfree = pagetok(swapary[0].ksw_total - swapary[0].ksw_used);
|
||||||
}
|
}
|
||||||
|
|
||||||
kvm_close(kvmd);
|
|
||||||
|
|
||||||
return (n);
|
return (n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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");
|
sock_send_string(sock, "widget_set S 1 1 1 Checking...\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Create a new process list */
|
||||||
procs = LL_new();
|
procs = LL_new();
|
||||||
if (procs == NULL) {
|
if (procs == NULL) {
|
||||||
fprintf(stderr, "mem_top_screen: Error allocating list\n");
|
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);
|
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... */
|
/* Now, print some info... */
|
||||||
LL_Rewind(procs);
|
LL_Rewind(procs);
|
||||||
@@ -325,7 +330,7 @@ mem_top_screen(int rep, int display, int *flags_ptr)
|
|||||||
LL_Next(procs);
|
LL_Next(procs);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now clean it all up... */
|
/* Delete the process list */
|
||||||
LL_Rewind(procs);
|
LL_Rewind(procs);
|
||||||
do {
|
do {
|
||||||
procinfo_type *p = (procinfo_type *) LL_Get(procs);
|
procinfo_type *p = (procinfo_type *) LL_Get(procs);
|
||||||
|
|||||||
Reference in New Issue
Block a user