mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-11-18 02:55:12 +00:00
Fix: make sure 51c928a8ef
works when programs terminate by themselves
This commit is contained in:
parent
51c928a8ef
commit
9ad3b9d8bc
10
src/conky.c
10
src/conky.c
@ -675,7 +675,7 @@ FILE* pid_popen(const char *command, const char *mode, pid_t *child) {
|
|||||||
return NULL;
|
return NULL;
|
||||||
} else if(*child > 0) {
|
} else if(*child > 0) {
|
||||||
close(childend);
|
close(childend);
|
||||||
waitpid(*child, NULL, WNOHANG);
|
waitpid(*child, NULL, 0);
|
||||||
} else {
|
} else {
|
||||||
//don't read from both stdin and pipe or write to both stdout and pipe
|
//don't read from both stdin and pipe or write to both stdout and pipe
|
||||||
if(childend == ends[0]) {
|
if(childend == ends[0]) {
|
||||||
@ -692,14 +692,15 @@ FILE* pid_popen(const char *command, const char *mode, pid_t *child) {
|
|||||||
|
|
||||||
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 = pid_popen(data, "r", &childpid);
|
FILE *fp;
|
||||||
|
|
||||||
|
alarm(update_interval);
|
||||||
|
fp = pid_popen(data, "r", &childpid);
|
||||||
if(fp) {
|
if(fp) {
|
||||||
int length;
|
int length;
|
||||||
|
|
||||||
alarm(update_interval);
|
|
||||||
length = fread(buf, 1, size, fp);
|
length = fread(buf, 1, size, fp);
|
||||||
pclose(fp);
|
pclose(fp);
|
||||||
alarm(0);
|
|
||||||
buf[length] = '\0';
|
buf[length] = '\0';
|
||||||
if (length > 0 && buf[length - 1] == '\n') {
|
if (length > 0 && buf[length - 1] == '\n') {
|
||||||
buf[length - 1] = '\0';
|
buf[length - 1] = '\0';
|
||||||
@ -707,6 +708,7 @@ static inline void read_exec(const char *data, char *buf, const int size)
|
|||||||
} else {
|
} else {
|
||||||
buf[0] = '\0';
|
buf[0] = '\0';
|
||||||
}
|
}
|
||||||
|
alarm(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void *threaded_exec(void *) __attribute__((noreturn));
|
void *threaded_exec(void *) __attribute__((noreturn));
|
||||||
|
Loading…
Reference in New Issue
Block a user