From 1447ae01bd10cbdb43ea596639ff01d717146084 Mon Sep 17 00:00:00 2001 From: Roberto De Ioris Date: Mon, 10 Dec 2012 15:10:52 +0100 Subject: [PATCH] improved uwsgi_run_command --- core/utils.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/core/utils.c b/core/utils.c index e949f46e..138bb49d 100644 --- a/core/utils.c +++ b/core/utils.c @@ -3295,7 +3295,27 @@ pid_t uwsgi_run_command(char *command, int *stdin_fd, int stdout_fd) { } uwsgi_close_all_sockets(); - uwsgi_close_all_fds(); + //uwsgi_close_all_fds(); + int i; + for (i = 3; i < (int) uwsgi.max_fd; i++) { + if (stdin_fd) { + if (i == stdin_fd[0] || i == stdin_fd[1]) { + continue; + } + } + if (stdout_fd > -1) { + if (i == stdout_fd) { + continue; + } + } +#ifdef __APPLE__ + fcntl(i, F_SETFD, FD_CLOEXEC); +#else + close(i); +#endif + } + + if (stdin_fd) { close(stdin_fd[1]);