From 725ed5ddeaed3ef6d9b86af8f8d170cb72710e98 Mon Sep 17 00:00:00 2001 From: Max Brazhnikov Date: Sat, 30 Oct 2010 11:43:47 +0000 Subject: [PATCH] Fix crash Remove md5 sum PR: ports/151668 Submitted by: Nikos Ntarmos (maintainer) --- sysutils/conky/Makefile | 1 + sysutils/conky/distinfo | 1 - sysutils/conky/files/patch-src-conky.c | 18 +++++++++- sysutils/conky/files/patch-src-exec.c | 28 +++++++++++++++ sysutils/conky/files/patch-src-freebsd.c | 44 ++++++++++++++++++++++++ sysutils/conky/files/patch-src-freebsd.h | 16 +++++++++ 6 files changed, 106 insertions(+), 2 deletions(-) create mode 100644 sysutils/conky/files/patch-src-exec.c create mode 100644 sysutils/conky/files/patch-src-freebsd.c create mode 100644 sysutils/conky/files/patch-src-freebsd.h diff --git a/sysutils/conky/Makefile b/sysutils/conky/Makefile index c06ac7b1d82e..a58c1355697a 100644 --- a/sysutils/conky/Makefile +++ b/sysutils/conky/Makefile @@ -7,6 +7,7 @@ PORTNAME= conky PORTVERSION= 1.8.1 +PORTREVISION= 1 CATEGORIES= sysutils MASTER_SITES= SF diff --git a/sysutils/conky/distinfo b/sysutils/conky/distinfo index bb275c3f7c71..9b1741538da7 100644 --- a/sysutils/conky/distinfo +++ b/sysutils/conky/distinfo @@ -1,3 +1,2 @@ -MD5 (conky-1.8.1.tar.bz2) = 366dc6a5c2ebebfbe6f53da25061b5d6 SHA256 (conky-1.8.1.tar.bz2) = f85a278f2869596b1fd68b6d26d58c93af8dcc39d5186bbcfd587d4c545e5e43 SIZE (conky-1.8.1.tar.bz2) = 612481 diff --git a/sysutils/conky/files/patch-src-conky.c b/sysutils/conky/files/patch-src-conky.c index b643ba5b82ce..3ff8111fa879 100644 --- a/sysutils/conky/files/patch-src-conky.c +++ b/sysutils/conky/files/patch-src-conky.c @@ -28,7 +28,23 @@ #endif /* AUDACIOUS */ #ifdef BMPX -@@ -6007,7 +6011,7 @@ +@@ -5716,6 +5720,7 @@ + "kvm_open")) == NULL) { + CRIT_ERR(NULL, NULL, "cannot read kvm"); + } ++ pthread_mutex_init(&kvm_proc_mutex, NULL); + #endif + + while (1) { +@@ -5999,6 +6004,7 @@ + + #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) + kvm_close(kd); ++ pthread_mutex_destroy(&kvm_proc_mutex); + #endif + + return 0; +@@ -6007,7 +6013,7 @@ void alarm_handler(void) { if(childpid > 0) { diff --git a/sysutils/conky/files/patch-src-exec.c b/sysutils/conky/files/patch-src-exec.c new file mode 100644 index 000000000000..78f0073d7f5c --- /dev/null +++ b/sysutils/conky/files/patch-src-exec.c @@ -0,0 +1,28 @@ +--- src/exec.c.orig 2010-10-27 20:19:48.000000000 +0300 ++++ src/exec.c 2010-10-27 20:19:52.000000000 +0300 +@@ -93,6 +93,7 @@ + } else { + close(1); + } ++ close(parentend); + dup(childend); //by dupping childend, the returned fd will have close-on-exec turned off + execl("/bin/sh", "sh", "-c", command, (char *) NULL); + _exit(EXIT_FAILURE); //child should die here, (normally execl will take care of this but it can fail) +@@ -156,7 +157,7 @@ + int length; + + length = fread(buf, 1, size, fp); +- pclose(fp); ++ fclose(fp); + buf[length] = '\0'; + if (length > 0 && buf[length - 1] == '\n') { + buf[length - 1] = '\0'; +@@ -320,7 +321,7 @@ + ed->buffer = malloc(text_buffer_size); + + length = fread(ed->buffer, 1, text_buffer_size, fp); +- pclose(fp); ++ fclose(fp); + + output = ed->buffer; + output[length] = '\0'; diff --git a/sysutils/conky/files/patch-src-freebsd.c b/sysutils/conky/files/patch-src-freebsd.c new file mode 100644 index 000000000000..957d8911c9e7 --- /dev/null +++ b/sysutils/conky/files/patch-src-freebsd.c @@ -0,0 +1,44 @@ +--- src/freebsd.c.orig 2010-10-24 03:14:05.000000000 +0300 ++++ src/freebsd.c 2010-10-24 03:13:05.000000000 +0300 +@@ -266,7 +266,9 @@ + { + int n_processes; + ++ pthread_mutex_lock(&kvm_proc_mutex); + kvm_getprocs(kd, KERN_PROC_ALL, 0, &n_processes); ++ pthread_mutex_unlock(&kvm_proc_mutex); + + info.procs = n_processes; + return 0; +@@ -278,6 +280,7 @@ + int n_processes; + int i, cnt = 0; + ++ pthread_mutex_lock(&kvm_proc_mutex); + p = kvm_getprocs(kd, KERN_PROC_ALL, 0, &n_processes); + for (i = 0; i < n_processes; i++) { + #if (__FreeBSD__ < 5) && (__FreeBSD_kernel__ < 5) +@@ -288,6 +291,7 @@ + cnt++; + } + } ++ pthread_mutex_unlock(&kvm_proc_mutex); + + info.run_procs = cnt; + return 0; +@@ -748,6 +752,7 @@ + CRIT_ERR(NULL, NULL, "Cannot read sysctl \"vm.stats.vm.v_page_count\""); + } + ++ pthread_mutex_lock(&kvm_proc_mutex); + p = kvm_getprocs(kd, KERN_PROC_PROC, 0, &n_processes); + processes = malloc(n_processes * sizeof(struct process)); + +@@ -764,6 +769,7 @@ + j++; + } + } ++ pthread_mutex_unlock(&kvm_proc_mutex); + + qsort(processes, j - 1, sizeof(struct process), comparemem); + for (i = 0; i < 10 && i < n_processes; i++) { diff --git a/sysutils/conky/files/patch-src-freebsd.h b/sysutils/conky/files/patch-src-freebsd.h new file mode 100644 index 000000000000..a18216b2f6e2 --- /dev/null +++ b/sysutils/conky/files/patch-src-freebsd.h @@ -0,0 +1,16 @@ +--- src/freebsd.h.orig 2010-10-24 03:14:11.000000000 +0300 ++++ src/freebsd.h 2010-10-24 03:13:05.000000000 +0300 +@@ -9,11 +9,13 @@ + #include + #include + #include ++#include + #if (defined(i386) || defined(__i386__)) + #include + #endif /* i386 || __i386__ */ + + kvm_t *kd; ++pthread_mutex_t kvm_proc_mutex; + + int get_entropy_avail(unsigned int *); + int get_entropy_poolsize(unsigned int *);