diff options
author | Klaus Schmidinger <vdr@tvdr.de> | 2002-02-17 14:51:29 +0100 |
---|---|---|
committer | Klaus Schmidinger <vdr@tvdr.de> | 2002-02-17 14:51:29 +0100 |
commit | aaf792357da5d9aaa0f8f61da78daf12508a69c4 (patch) | |
tree | f1aba2d66d390e9a3a47836e38b04b272e3ce80a /thread.c | |
parent | e18b303818ee1ac918176ce07eb64d3d02ae122a (diff) | |
download | vdr-aaf792357da5d9aaa0f8f61da78daf12508a69c4.tar.gz vdr-aaf792357da5d9aaa0f8f61da78daf12508a69c4.tar.bz2 |
Fixed closing all unused file descriptors when opening a pipe
Diffstat (limited to 'thread.c')
-rw-r--r-- | thread.c | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: thread.c 1.16 2001/10/27 13:23:06 kls Exp $ + * $Id: thread.c 1.17 2002/02/17 14:47:28 kls Exp $ */ #include "thread.h" @@ -277,8 +277,11 @@ bool cPipe::Open(const char *Command, const char *Mode) _exit(-1); } else { - for (int i = STDERR_FILENO + 1; i < fd[1 - iopipe]; i++) - close(i); //close all dup'ed filedescriptors + for (int i = 0; i <= fd[1]; i++) { + if (i == STDIN_FILENO || i == STDOUT_FILENO || i == STDERR_FILENO) + continue; + close(i); // close all dup'ed filedescriptors + } if (execl("/bin/sh", "sh", "-c", Command, NULL) == -1) { LOG_ERROR_STR(Command); close(fd[1 - iopipe]); |