1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-11-15 17:47:09 +00:00

fclose(3) instead of pclose(3) as the latter seems to leak file descriptors

Signed-off-by: Nikos Ntarmos <ntarmos@cs.uoi.gr>
Signed-off-by: Pavel Labath <pavelo@centrum.sk>

Conflicts:

	src/exec.c - had to merge manually
This commit is contained in:
Pavel Labath 2010-12-05 21:16:01 +01:00
parent 43d81169f6
commit f1bc24f199

View File

@ -95,6 +95,7 @@ static FILE* pid_popen(const char *command, const char *mode, pid_t *child) {
} else {
close(1);
}
close(parentend);
//by dupping childend, the returned fd will have close-on-exec turned off
if (dup(childend) == -1)
@ -161,7 +162,7 @@ static inline void read_exec(const char *data, char *buf, const int size)
int length;
length = fread(buf, 1, size, fp);
pclose(fp);
fclose(fp);
buf[std::min(length, size-1)] = '\0';
if (length > 0 && buf[length - 1] == '\n') {
buf[length - 1] = '\0';