diff --git a/core/master_utils.c b/core/master_utils.c index d67be6394..22977c07b 100644 --- a/core/master_utils.c +++ b/core/master_utils.c @@ -54,12 +54,6 @@ void uwsgi_destroy_processes() { uwsgi_detach_daemons(); - for (i = 1; i <= uwsgi.numproc; i++) { - if (uwsgi.workers[i].pid > 0) { - waitpid(uwsgi.workers[i].pid, &waitpid_status, 0); - } - } - for (i = 0; i < ushared->gateways_cnt; i++) { if (ushared->gateways[i].pid > 0) { kill(ushared->gateways[i].pid, SIGKILL); diff --git a/core/uwsgi.c b/core/uwsgi.c index 485fe4986..36004dce3 100755 --- a/core/uwsgi.c +++ b/core/uwsgi.c @@ -1356,6 +1356,8 @@ void kill_them_all(int signum) { // gracefully destroy void gracefully_kill_them_all(int signum) { + int waitpid_status; + if (uwsgi_instance_is_dying) return; uwsgi.status.gracefully_destroying = 1; @@ -1377,6 +1379,12 @@ void gracefully_kill_them_all(int signum) { } } + for (i = 1; i <= uwsgi.numproc; i++) { + if (uwsgi.workers[i].pid > 0) { + waitpid(uwsgi.workers[i].pid, &waitpid_status, 0); + } + } + uwsgi_destroy_processes(); }