From 57bade7eaec884918ebd9d1b0b250090a6162816 Mon Sep 17 00:00:00 2001 From: "roberto@precise64" Date: Wed, 29 Feb 2012 14:57:44 +0100 Subject: [PATCH] close stdin in vassals --- emperor.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/emperor.c b/emperor.c index f37b4015..cd0a2946 100644 --- a/emperor.c +++ b/emperor.c @@ -379,8 +379,22 @@ void emperor_add(char *name, time_t born, char *config, uint32_t config_size, ui } vassal_argv[counter] = NULL; + // disable stdin + int stdin_fd = open("/dev/null", O_RDONLY); + if (stdin_fd < 0) { + uwsgi_error_open("/dev/null"); + exit(1); + } + if (stdin_fd != 0) { + if (dup2(stdin_fd, 0)) { + uwsgi_error("dup2()"); + exit(1); + } + close(stdin_fd); + } + // close all of the unneded fd - for(i=3;ipipe[1]) { close(i); } @@ -435,6 +449,7 @@ void emperor_loop() { int nevents; int interesting_fd; char notification_message[64]; + struct rlimit rl; uwsgi.emperor_stats_fd = -1; @@ -446,6 +461,13 @@ void emperor_loop() { memset(&ui_base, 0, sizeof(struct uwsgi_instance)); + if (getrlimit(RLIMIT_NOFILE, &rl)) { + uwsgi_error("getrlimit()"); + exit(1); + } + + uwsgi.max_fd = rl.rlim_cur; + emperor_queue = event_queue_init();