1
0
mirror of https://github.com/VDR4Arch/vdr.git synced 2023-10-10 13:36:52 +02:00

Fixed closing all dup'ed file descriptors in cPipe

This commit is contained in:
Klaus Schmidinger 2002-11-02 14:00:25 +01:00
parent dd59830a92
commit 2e26a1d607

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: thread.c 1.22 2002/08/15 11:44:48 kls Exp $ * $Id: thread.c 1.23 2002/11/02 14:00:25 kls Exp $
*/ */
#include "thread.h" #include "thread.h"
@ -331,11 +331,9 @@ bool cPipe::Open(const char *Command, const char *Mode)
_exit(-1); _exit(-1);
} }
else { else {
for (int i = 0; i <= fd[1]; i++) { int MaxPossibleFileDescriptors = getdtablesize();
if (i == STDIN_FILENO || i == STDOUT_FILENO || i == STDERR_FILENO) for (int i = STDERR_FILENO + 1; i < MaxPossibleFileDescriptors; i++)
continue; close(i); //close all dup'ed filedescriptors
close(i); // close all dup'ed filedescriptors
}
if (execl("/bin/sh", "sh", "-c", Command, NULL) == -1) { if (execl("/bin/sh", "sh", "-c", Command, NULL) == -1) {
LOG_ERROR_STR(Command); LOG_ERROR_STR(Command);
close(fd[1 - iopipe]); close(fd[1 - iopipe]);