mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-10-03 07:29:10 +00:00
Handle if popen should fail
This commit is contained in:
parent
41f9e67f96
commit
81f82b4b81
@ -640,6 +640,7 @@ static struct text_object global_root_object;
|
|||||||
static inline void read_exec(const char *data, char *buf, const int size)
|
static inline void read_exec(const char *data, char *buf, const int size)
|
||||||
{
|
{
|
||||||
FILE *fp = popen(data, "r");
|
FILE *fp = popen(data, "r");
|
||||||
|
if(fp) {
|
||||||
int length = fread(buf, 1, size, fp);
|
int length = fread(buf, 1, size, fp);
|
||||||
|
|
||||||
pclose(fp);
|
pclose(fp);
|
||||||
@ -647,6 +648,9 @@ static inline void read_exec(const char *data, char *buf, const int size)
|
|||||||
if (length > 0 && buf[length - 1] == '\n') {
|
if (length > 0 && buf[length - 1] == '\n') {
|
||||||
buf[length - 1] = '\0';
|
buf[length - 1] = '\0';
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
buf[0] = '\0';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void *threaded_exec(void *) __attribute__((noreturn));
|
void *threaded_exec(void *) __attribute__((noreturn));
|
||||||
|
Loading…
Reference in New Issue
Block a user