projects
/
monky
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
febc530
)
Handle if popen should fail
author
Nikolas Garofil
<garo@dunaldi.garofil.be>
Sat, 25 Jul 2009 12:36:55 +0000
(14:36 +0200)
committer
Nikolas Garofil
<garo@dunaldi.garofil.be>
Sat, 25 Jul 2009 12:36:55 +0000
(14:36 +0200)
src/conky.c
patch
|
blob
|
history
diff --git
a/src/conky.c
b/src/conky.c
index
64f5070
..
b19ea8e
100644
(file)
--- a/
src/conky.c
+++ b/
src/conky.c
@@
-642,12
+642,16
@@
static struct text_object global_root_object;
static inline void read_exec(const char *data, char *buf, const int size)
{
FILE *fp = popen(data, "r");
- int length = fread(buf, 1, size, fp);
+ if(fp) {
+ int length = fread(buf, 1, size, fp);
- pclose(fp);
- buf[length] = '\0';
- if (length > 0 && buf[length - 1] == '\n') {
- buf[length - 1] = '\0';
+ pclose(fp);
+ buf[length] = '\0';
+ if (length > 0 && buf[length - 1] == '\n') {
+ buf[length - 1] = '\0';
+ }
+ } else {
+ buf[0] = '\0';
}
}