From 19857a55216931b4a7a5d6d3d2b0b4ee5e8d567a Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Wed, 20 Feb 2013 15:20:55 +0100 Subject: [PATCH] my_popen: close filedescriptors before exec Signed-off-by: Jacek Jendrzej Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/3064107b907d8f564044841a2f1fd393cef3b4b7 Author: Stefan Seyfried Date: 2013-02-20 (Wed, 20 Feb 2013) ------------------ This commit was generated by Migit --- src/system/helpers.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/system/helpers.cpp b/src/system/helpers.cpp index 16ca36bd0..998dcabaa 100644 --- a/src/system/helpers.cpp +++ b/src/system/helpers.cpp @@ -129,6 +129,9 @@ FILE* my_popen( pid_t& pid, const char *cmdstring, const char *type) close(pfd[0]); } } + int maxfd = getdtablesize(); + for(int i = 3; i < maxfd; i++) + close(i); execl("/bin/sh", "sh", "-c", cmdstring, (char *)0); exit(0); }