From c83a35ebfc41c0ae0441a9a6c7c36984f861b96c 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 --- src/system/helpers.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/system/helpers.cpp b/src/system/helpers.cpp index 56b29b6c6..c61f7e3c1 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); }