From 1ebfeda1d2cb1a6431c6a0ce36979e842188e466 Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Fri, 26 Jan 2007 13:35:52 +0100 Subject: [PATCH] Now using cPipe instead of popen() in cCommand::Execute() --- CONTRIBUTORS | 2 ++ HISTORY | 3 +++ config.c | 8 ++++---- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 2f5581ef..aeb7df4b 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -1114,6 +1114,8 @@ Reinhard Nissl for changing the behaviour when hitting the end of a recording in fast forward mode for suggesting to give the cRemote::CallPlugin() function a boolean return value for fixing a possible crash in remux.c on 64-bit machines + for making cCommand::Execute() use cPipe instead of popen() to avoid problems + with open file handles when starting background commands Richard Robson for reporting freezing replay if a timer starts while in Transfer Mode from the diff --git a/HISTORY b/HISTORY index dacfc641..86f40fa2 100644 --- a/HISTORY +++ b/HISTORY @@ -5032,3 +5032,6 @@ Video Disk Recorder Revision History 2007-01-26: Version 1.4.5-1 - Fixed i18n characters for the Hungarian texts (thanks to Thomas Günther). +- Now using cPipe instead of popen() in cCommand::Execute() to avoid problems + with open file handles when starting background commands (thanks to Reinhard + Nissl). diff --git a/config.c b/config.c index f3942668..5edaece9 100644 --- a/config.c +++ b/config.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: config.c 1.146 2006/07/22 11:57:51 kls Exp $ + * $Id: config.c 1.146.1.1 2007/01/26 13:32:19 kls Exp $ */ #include "config.h" @@ -67,8 +67,8 @@ const char *cCommand::Execute(const char *Parameters) asprintf(&cmdbuf, "%s %s", command, Parameters); const char *cmd = cmdbuf ? cmdbuf : command; dsyslog("executing command '%s'", cmd); - FILE *p = popen(cmd, "r"); - if (p) { + cPipe p; + if (p.Open(cmd, "r")) { int l = 0; int c; while ((c = fgetc(p)) != EOF) { @@ -78,7 +78,7 @@ const char *cCommand::Execute(const char *Parameters) } if (result) result[l] = 0; - pclose(p); + p.Close(); } else esyslog("ERROR: can't open pipe for command '%s'", cmd);