diff --git a/emperor.c b/emperor.c index d601f161..5a931f32 100644 --- a/emperor.c +++ b/emperor.c @@ -328,7 +328,12 @@ void emperor_loop() { events = event_queue_alloc(64); - uwsgi_log("*** starting uWSGI Emperor ***\n"); + if (uwsgi.has_emperor) { + uwsgi_log("*** starting uWSGI sub-Emperor ***\n"); + } + else { + uwsgi_log("*** starting uWSGI Emperor ***\n"); + } amqp_port = strchr(uwsgi.emperor_dir, ':'); @@ -356,7 +361,7 @@ reconnect: event_queue_add_fd_read(emperor_queue, amqp_fd); } else { - if (!glob(uwsgi.emperor_dir, GLOB_MARK, NULL, &g)) { + if (!glob(uwsgi.emperor_dir, GLOB_MARK|GLOB_NOCHECK, NULL, &g)) { if (g.gl_pathc == 1 && g.gl_pathv[0][strlen(g.gl_pathv[0]) - 1] == '/') { simple_mode = 1; if (chdir(uwsgi.emperor_dir)) { @@ -531,7 +536,7 @@ reconnect: closedir(dir); } else { - if (glob(uwsgi.emperor_dir, GLOB_MARK, NULL, &g)) { + if (glob(uwsgi.emperor_dir, GLOB_MARK|GLOB_NOCHECK, NULL, &g)) { uwsgi_error("glob()"); continue; } diff --git a/uwsgi.c b/uwsgi.c index a92bb7c2..54d9a6fd 100644 --- a/uwsgi.c +++ b/uwsgi.c @@ -422,6 +422,7 @@ void kill_them_all(int signum) { if (uwsgi.emperor_pid >= 0) { kill(uwsgi.emperor_pid, SIGKILL); + waitpid(uwsgi.emperor_pid, &i, 0); uwsgi_log( "killed the emperor with pid %d\n", uwsgi.emperor_pid); } @@ -456,6 +457,7 @@ void grace_them_all(int signum) { if (uwsgi.emperor_pid >= 0) { kill(uwsgi.emperor_pid, SIGKILL); + waitpid(uwsgi.emperor_pid, &i, 0); uwsgi_log( "killed the emperor with pid %d\n", uwsgi.emperor_pid); } @@ -529,6 +531,12 @@ void reap_them_all(int signum) { kill(uwsgi.gateways[i].pid, SIGKILL); } + if (uwsgi.emperor_pid >= 0) { + kill(uwsgi.emperor_pid, SIGKILL); + waitpid(uwsgi.emperor_pid, &i, 0); + uwsgi_log( "killed the emperor with pid %d\n", uwsgi.emperor_pid); + } + if (!uwsgi.workers) return; @@ -1357,6 +1365,11 @@ int uwsgi_start(void *v_argv) { exit(1); } else if (uwsgi.emperor_pid == 0) { +#ifdef __linux__ + if (prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0)) { + uwsgi_error("prctl()"); + } +#endif emperor_loop(); // never here exit(1); @@ -1743,7 +1756,7 @@ int uwsgi_start(void *v_argv) { } #endif - if (!uwsgi.sockets && !uwsgi.gateways_cnt && !uwsgi.no_server && !uwsgi.udp_socket) { + if (!uwsgi.sockets && !uwsgi.gateways_cnt && !uwsgi.no_server && !uwsgi.udp_socket && !uwsgi.emperor_dir) { uwsgi_log("The -s/--socket option is missing and stdin is not a socket.\n"); exit(1); }