changeset 279:b79f021a644a

nginx-0.0.2-2004-03-04-19:34:23 import
author Igor Sysoev <igor@sysoev.ru>
date Thu, 04 Mar 2004 16:34:23 +0000
parents 0ba4821f4460
children 7c7183b3ea8b
files auto/cc auto/make auto/types/typedef auto/unix src/core/nginx.c src/os/unix/ngx_process.c src/os/unix/ngx_process.h src/os/unix/ngx_process_cycle.c src/os/unix/ngx_thread.h src/os/win32/ngx_process.h src/os/win32/ngx_win32_config.h
diffstat 11 files changed, 53 insertions(+), 588 deletions(-) [+]
line wrap: on
line diff
--- a/auto/cc
+++ b/auto/cc
@@ -119,4 +119,9 @@ case $CC in
          CC_STRONG="$CC -W3 -WX"
     ;;
 
+
+    wcc386)
+         # Open Watcom 1.0
+    ;;
+
 esac
--- a/auto/make
+++ b/auto/make
@@ -43,7 +43,10 @@ do
 done
 echo                                          >> $MAKEFILE
 
-inc=`echo "$CORE_INCS -I $OBJS" | sed -e "s/\//\\\\\\/g"`
+inc="$CORE_INCS -I $OBJS"
+if [ $PLATFORM = win32 ]; then
+    inc=`echo $inc | sed -e "s/\//\\\\\\/g"`
+fi
 echo "CORE_INCS = $inc"                       >> $MAKEFILE
 echo                                          >> $MAKEFILE
 
@@ -57,7 +60,10 @@ do
 done
 echo                                          >> $MAKEFILE
 
-inc=`echo "$HTTP_INCS" | sed -e "s/\//\\\\\\/g"`
+inc="$HTTP_INCS"
+if [ $PLATFORM = win32 ]; then
+    inc=`echo $inc | sed -e "s/\//\\\\\\/g"`
+fi
 echo "HTTP_INCS = $inc"                       >> $MAKEFILE
 echo                                          >> $MAKEFILE
 
--- a/auto/types/typedef
+++ b/auto/types/typedef
@@ -10,9 +10,9 @@ do
 
     cat << END > $NGX_AUTOTEST.c
 
+#include <signal.h>
 #include <sys/types.h>
 #include <sys/socket.h>
-#include <sys/signal.h>
 #include <sys/time.h>
 #include <sys/resource.h>
 #include <netinet/in.h>
--- a/auto/unix
+++ b/auto/unix
@@ -25,8 +25,8 @@ NGX_AUTO_CONFIG="#include \"../$NGX_AUTO
 ngx_type="uint64_t"
 ngx_types="u_int64_t"; . auto/types/typedef
 
-#ngx_type="sig_atomic_t"
-#ngx_types="int"; . auto/types/typedef
+ngx_type="sig_atomic_t"
+ngx_types="int"; . auto/types/typedef
 
 ngx_type="socklen_t"
 ngx_types="uint32_t"; . auto/types/typedef
--- a/src/core/nginx.c
+++ b/src/core/nginx.c
@@ -256,501 +256,6 @@ int main(int argc, char *const *argv, ch
 }
 
 
-#if 0
-
-/* TODO: broken NGX_PROCESS_SINGLE */
-
-static void ngx_master_process_cycle(ngx_cycle_t *cycle, ngx_master_ctx_t *ctx)
-{
-    int                signo;
-    sigset_t           set;
-    struct timeval     tv;
-    struct itimerval   itv;
-    ngx_uint_t         i, live;
-    ngx_msec_t         delay;
-    ngx_core_conf_t   *ccf;
-
-    sigemptyset(&set);
-    sigaddset(&set, SIGCHLD);
-    sigaddset(&set, SIGALRM);
-    sigaddset(&set, SIGINT);
-    sigaddset(&set, ngx_signal_value(NGX_RECONFIGURE_SIGNAL));
-    sigaddset(&set, ngx_signal_value(NGX_REOPEN_SIGNAL));
-    sigaddset(&set, ngx_signal_value(NGX_NOACCEPT_SIGNAL));
-    sigaddset(&set, ngx_signal_value(NGX_TERMINATE_SIGNAL));
-    sigaddset(&set, ngx_signal_value(NGX_SHUTDOWN_SIGNAL));
-    sigaddset(&set, ngx_signal_value(NGX_CHANGEBIN_SIGNAL));
-
-    if (sigprocmask(SIG_BLOCK, &set, NULL) == -1) {
-        ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
-                      "sigprocmask() failed");
-    }
-
-    sigemptyset(&set);
-
-    ngx_setproctitle("master process");
-
-    ngx_new_binary = 0;
-    delay = 0;
-    signo = 0;
-    live = 0;
-
-    for ( ;; ) {
-        ngx_log_debug0(NGX_LOG_DEBUG_EVENT, cycle->log, 0, "new cycle");
-
-        if (ngx_process == NGX_PROCESS_MASTER) {
-            ngx_spawn_process(cycle, ngx_worker_process_cycle, NULL,
-                              "worker process", NGX_PROCESS_RESPAWN);
-
-            /*
-             * we have to limit the maximum life time of the worker processes
-             * by 1 month because our millisecond event timer is limited
-             * by 49 days on 32-bit platforms
-             */
-
-            itv.it_interval.tv_sec = 0;
-            itv.it_interval.tv_usec = 0;
-            itv.it_value.tv_sec = 30 * 24 * 60 * 60;
-            itv.it_value.tv_usec = 0;
-
-            if (setitimer(ITIMER_REAL, &itv, NULL) == -1) {
-                ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
-                              "setitimer() failed");
-            }
-
-            live = 1;
-
-        } else {
-            ngx_init_temp_number();
-
-            for (i = 0; ngx_modules[i]; i++) {
-                if (ngx_modules[i]->init_process) {
-                    if (ngx_modules[i]->init_process(cycle) == NGX_ERROR) {
-                        /* fatal */
-                        exit(1);
-                    }
-                }
-            }
-        }
-
-        ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx,
-                                               ngx_core_module);
-
-        /* a cycle with the same configuration because a new one is invalid */
-
-        for ( ;; ) {
-
-            /* an event loop */
-
-            for ( ;; ) {
-
-                if (ngx_process == NGX_PROCESS_MASTER) {
-                    if (delay) {
-                        delay *= 2;
-
-                        ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
-                                       "temination cycle: %d", delay);
-
-                        itv.it_interval.tv_sec = 0;
-                        itv.it_interval.tv_usec = 0;
-                        itv.it_value.tv_sec = delay / 1000;
-                        itv.it_value.tv_usec = (delay % 1000 ) * 1000;
-
-                        if (setitimer(ITIMER_REAL, &itv, NULL) == -1) {
-                            ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
-                                          "setitimer() failed");
-                        }
-                    }
-
-                    ngx_log_debug0(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
-                                   "sigsuspend");
-
-                    sigsuspend(&set);
-
-                    ngx_gettimeofday(&tv);
-                    ngx_time_update(tv.tv_sec);
-
-                    ngx_log_debug0(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
-                                   "wake up");
-
-                } else { /* NGX_PROCESS_SINGLE */
-                    ngx_log_debug0(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
-                                   "worker cycle");
-
-                    ngx_process_events(cycle->log);
-                    live = 0;
-                }
-
-                if (ngx_reap) {
-                    ngx_reap = 0;
-                    ngx_log_debug0(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
-                                   "reap childs");
-
-                    live = 0;
-                    for (i = 0; i < ngx_last_process; i++) {
-
-                        ngx_log_debug5(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
-                                       "child: " PID_T_FMT
-                                       " e:%d t:%d d:%d r:%d",
-                                       ngx_processes[i].pid,
-                                       ngx_processes[i].exiting,
-                                       ngx_processes[i].exited,
-                                       ngx_processes[i].detached,
-                                       ngx_processes[i].respawn);
-
-                        if (ngx_processes[i].exited) {
-
-                            if (ngx_processes[i].respawn
-                                && !ngx_processes[i].exiting
-                                && !ngx_terminate
-                                && !ngx_quit)
-                            {
-                                 if (ngx_spawn_process(cycle,
-                                                       ngx_processes[i].proc,
-                                                       ngx_processes[i].data,
-                                                       ngx_processes[i].name, i)
-                                                                  == NGX_ERROR)
-                                 {
-                                     ngx_log_error(NGX_LOG_ALERT, cycle->log, 0,
-                                                   "can not respawn %s",
-                                                   ngx_processes[i].name);
-                                     continue;
-                                 }
-
-                                 live = 1;
-
-                                 continue;
-                            }
-
-                            if (ngx_processes[i].pid == ngx_new_binary) {
-                                ngx_new_binary = 0;
-
-                                /* TODO: if (ngx_noaccept) ngx_configure = 1 */
-                            }
-
-                            if (i != --ngx_last_process) {
-                                ngx_processes[i--] =
-                                               ngx_processes[ngx_last_process];
-                            }
-
-                        } else if (ngx_processes[i].exiting
-                                   || !ngx_processes[i].detached)
-                        {
-                            live = 1;
-                        }
-                    }
-                }
-
-                if (!live && (ngx_terminate || ngx_quit)) {
-                    ngx_master_exit(cycle, ctx);
-                }
-
-                if (ngx_terminate) {
-                    if (delay == 0) {
-                        delay = 50;
-                    }
-
-                    if (delay > 1000) {
-                        signo = SIGKILL;
-                    } else {
-                        signo = ngx_signal_value(NGX_TERMINATE_SIGNAL);
-                    }
-
-                } else if (ngx_quit) {
-                    signo = ngx_signal_value(NGX_SHUTDOWN_SIGNAL);
-
-                } else if (ngx_timer) {
-                    signo = ngx_signal_value(NGX_SHUTDOWN_SIGNAL);
-
-                } else {
-
-                    if (ngx_noaccept) {
-                        signo = ngx_signal_value(NGX_SHUTDOWN_SIGNAL);
-                    }
-
-                    if (ngx_change_binary) {
-                        ngx_change_binary = 0;
-                        ngx_log_error(NGX_LOG_INFO, cycle->log, 0,
-                                      "changing binary");
-                        ngx_new_binary = ngx_exec_new_binary(cycle, ctx->argv);
-                    }
-
-                    if (ngx_reconfigure) {
-                        signo = ngx_signal_value(NGX_SHUTDOWN_SIGNAL);
-                        ngx_log_error(NGX_LOG_INFO, cycle->log, 0,
-                                      "reconfiguring");
-                    }
-
-                    if (ngx_reopen) {
-                        if (ngx_process == NGX_PROCESS_MASTER) {
-                            if (ccf->worker_reopen != 0) {
-                                signo = ngx_signal_value(NGX_REOPEN_SIGNAL);
-                                ngx_reopen = 0;
-
-                            } else if (ngx_noaccept) {
-                                ngx_reopen = 0;
-
-                            } else {
-                                signo = ngx_signal_value(NGX_SHUTDOWN_SIGNAL);
-                            }
-
-                        } else { /* NGX_PROCESS_SINGLE */
-                            ngx_reopen = 0;
-                        }
-
-                        ngx_log_error(NGX_LOG_INFO, cycle->log, 0,
-                                      "reopening logs");
-                        ngx_reopen_files(cycle,
-                             ccf->worker_reopen != 0 ? ccf->user : (uid_t) -1);
-                    }
-                }
-
-                if (signo) {
-                    for (i = 0; i < ngx_last_process; i++) {
-
-                        if (ngx_processes[i].detached) {
-                            continue;
-                        }
-
-                        ngx_log_debug2(NGX_LOG_DEBUG_CORE, cycle->log, 0,
-                                       "kill (" PID_T_FMT ", %d)" ,
-                                       ngx_processes[i].pid, signo);
-
-                        if (kill(ngx_processes[i].pid, signo) == -1) {
-                            ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
-                                          "kill(%d, %d) failed",
-                                          ngx_processes[i].pid, signo);
-                            continue;
-                        }
-
-                        if (signo != ngx_signal_value(NGX_REOPEN_SIGNAL)) {
-                            ngx_processes[i].exiting = 1;
-                        }
-                    }
-
-                    signo = 0;
-                }
-
-                if (ngx_reopen || ngx_reconfigure || ngx_timer) {
-                    break;
-                }
-            }
-
-            if (ngx_reopen) {
-                ngx_reopen = 0;
-
-            } else if (ngx_timer) {
-                ngx_timer = 0;
-
-            } else if (ngx_noaccept) {
-                ngx_noaccept = 0;
-                ngx_reconfigure = 0;
-
-            } else {
-                cycle = ngx_init_cycle(cycle);
-                if (cycle == NULL) {
-                    cycle = (ngx_cycle_t *) ngx_cycle;
-                    continue;
-                }
-
-                ngx_cycle = cycle;
-                ngx_reconfigure = 0;
-            }
-
-            break;
-        }
-    }
-}
-
-
-static void ngx_master_exit(ngx_cycle_t *cycle, ngx_master_ctx_t *ctx)
-{
-    char  *name;
-
-    if (ngx_inherited && getppid() > 1) {
-        name = ctx->pid.name.data;
-
-    } else {
-        name = ctx->name;
-    }
-
-    if (ngx_delete_file(name) == NGX_FILE_ERROR) {
-        ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
-                      ngx_delete_file_n " \"%s\" failed", name);
-    }
-
-    ngx_log_error(NGX_LOG_INFO, cycle->log, 0, "exit");
-    exit(0);
-}
-
-
-static void ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data)
-{
-    sigset_t          set;
-    ngx_int_t         i;
-    ngx_listening_t  *ls;
-    ngx_core_conf_t  *ccf;
-#if (NGX_THREADS)
-    ngx_tid_t         tid;
-#endif
-
-    ngx_process = NGX_PROCESS_WORKER;
-    ngx_last_process = 0;
-
-    ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module);
-
-    if (ccf->group != (gid_t) NGX_CONF_UNSET) {
-        if (setuid(ccf->group) == -1) {
-            ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
-                          "setgid(%d) failed", ccf->group);
-            /* fatal */
-            exit(2);
-        }
-    }
-
-    if (ccf->user != (uid_t) NGX_CONF_UNSET && geteuid() == 0) {
-        if (setuid(ccf->user) == -1) {
-            ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
-                          "setuid(%d) failed", ccf->user);
-            /* fatal */
-            exit(2);
-        }
-    }
-
-#if (HAVE_PR_SET_DUMPABLE)
-
-    /* allow coredump after setuid() in Linux 2.4.x */
-
-    if (prctl(PR_SET_DUMPABLE, 1, 0, 0, 0) == -1) {
-        ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
-                      "prctl(PR_SET_DUMPABLE) failed");
-    }
-
-#endif
-
-    sigemptyset(&set);
-
-    if (sigprocmask(SIG_SETMASK, &set, NULL) == -1) {
-        ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
-                      "sigprocmask() failed");
-    }
-
-    ngx_init_temp_number();
-
-    /*
-     * disable deleting previous events for the listening sockets because
-     * in the worker processes there are no events at all at this point
-     */ 
-    ls = cycle->listening.elts;
-    for (i = 0; i < cycle->listening.nelts; i++) {
-        ls[i].remain = 0;
-    }
-
-    for (i = 0; ngx_modules[i]; i++) {
-        if (ngx_modules[i]->init_process) {
-            if (ngx_modules[i]->init_process(cycle) == NGX_ERROR) {
-                /* fatal */
-                exit(1);
-            }
-        }
-    }
-
-    ngx_setproctitle("worker process");
-
-#if (NGX_THREADS)
-
-    if (ngx_init_threads(5, 128 * 1024 * 1024, cycle) == NGX_ERROR) {
-        /* fatal */
-        exit(1);
-    }
-
-    for (i = 0; i < 1; i++) {
-        if (ngx_create_thread(&tid, ngx_worker_thread_cycle,
-                              cycle, cycle->log) != 0)
-        {
-            /* fatal */
-            exit(1);
-        }
-    }
-
-#endif
-
-    for ( ;; ) {
-        ngx_log_debug0(NGX_LOG_DEBUG_EVENT, cycle->log, 0, "worker cycle");
-
-        ngx_process_events(cycle->log);
-
-        if (ngx_terminate) {
-            ngx_log_error(NGX_LOG_INFO, cycle->log, 0, "exiting");
-            exit(0);
-        }
-
-        if (ngx_quit) {
-            ngx_log_error(NGX_LOG_INFO, cycle->log, 0,
-                          "gracefully shutting down");
-            ngx_setproctitle("worker process is shutting down");
-            break;
-        }
-
-        if (ngx_reopen) {
-            ngx_log_error(NGX_LOG_INFO, cycle->log, 0, "reopen logs");
-            ngx_reopen_files(cycle, -1);
-            ngx_reopen = 0;
-        }
-    }
-
-    ngx_close_listening_sockets(cycle);
-
-    for ( ;; ) {
-        if (ngx_event_timer_rbtree == &ngx_event_timer_sentinel) {
-            ngx_log_error(NGX_LOG_INFO, cycle->log, 0, "exiting");
-            exit(0);
-        }
-
-        ngx_log_debug0(NGX_LOG_DEBUG_EVENT, cycle->log, 0, "worker cycle");
-
-        ngx_process_events(cycle->log);
-
-        if (ngx_reopen) {
-            ngx_log_error(NGX_LOG_INFO, cycle->log, 0, "reopen logs");
-            ngx_reopen_files(cycle, -1);
-            ngx_reopen = 0;
-        }
-    }
-}
-
-
-#if (NGX_THREADS)
-
-int ngx_worker_thread_cycle(void *data)
-{
-    ngx_cycle_t *cycle = data;
-
-    struct timeval  tv;
-
-    /* STUB */
-
-    ngx_log_debug1(NGX_LOG_DEBUG_CORE, ngx_cycle->log, ngx_errno,
-                   "thread %d started", ngx_thread_self());
-
-    ngx_setproctitle("worker thread");
-
-    sleep(5);
-
-    ngx_gettimeofday(&tv);
-    ngx_time_update(tv.tv_sec);
-
-    ngx_log_debug1(NGX_LOG_DEBUG_CORE, ngx_cycle->log, ngx_errno,
-                   "thread %d done", ngx_thread_self());
-
-    return 1;
-}
-
-#endif
-
-#endif
-
-
 static ngx_int_t ngx_add_inherited_sockets(ngx_cycle_t *cycle, char **envp)
 {
     char                *p, *v;
@@ -824,7 +329,7 @@ ngx_pid_t ngx_exec_new_binary(ngx_cycle_
     env[1] = NULL;
     ctx.envp = (char *const *) &env;
 
-    pid = ngx_exec(cycle, &ctx);
+    pid = ngx_execute(cycle, &ctx);
 
     ngx_free(var);
 
--- a/src/os/unix/ngx_process.c
+++ b/src/os/unix/ngx_process.c
@@ -3,7 +3,7 @@
 #include <ngx_core.h>
 
 
-static void ngx_exec_proc(ngx_cycle_t *cycle, void *data);
+static void ngx_execute_proc(ngx_cycle_t *cycle, void *data);
 
 ngx_uint_t     ngx_last_process;
 ngx_process_t  ngx_processes[NGX_MAX_PROCESSES];
@@ -13,23 +13,8 @@ ngx_pid_t ngx_spawn_process(ngx_cycle_t 
                             ngx_spawn_proc_pt proc, void *data,
                             char *name, ngx_int_t respawn)
 {
-#if 0
-    sigset_t   set, oset;
-#endif
     ngx_pid_t  pid;
 
-#if 0
-    if (respawn < 0) {
-        sigemptyset(&set);
-        sigaddset(&set, SIGCHLD);
-        if (sigprocmask(SIG_BLOCK, &set, &oset) == -1) {
-            ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
-                          "sigprocmask() failed while spawning %s", name);
-            return NGX_ERROR;
-        }
-    }
-#endif
-
     pid = fork();
 
     if (pid == -1) {
@@ -37,16 +22,6 @@ ngx_pid_t ngx_spawn_process(ngx_cycle_t 
                       "fork() failed while spawning \"%s\"", name);
     }
 
-    if (pid == -1 || pid == 0) {
-#if 0
-        if (sigprocmask(SIG_SETMASK, &oset, &set) == -1) {
-            ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
-                          "sigprocmask() failed while spawning %s", name);
-            return NGX_ERROR;
-        }
-#endif
-    }
-
     switch (pid) {
     case -1:
         return NGX_ERROR;
@@ -81,26 +56,18 @@ ngx_pid_t ngx_spawn_process(ngx_cycle_t 
     ngx_processes[ngx_last_process].exiting = 0;
     ngx_last_process++;
 
-#if 0
-    if (sigprocmask(SIG_SETMASK, &oset, &set) == -1) {
-        ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
-                      "sigprocmask() failed while spawning %s", name);
-        return NGX_ERROR;
-    }
-#endif
-
     return pid;
 }
 
 
-ngx_pid_t ngx_exec(ngx_cycle_t *cycle, ngx_exec_ctx_t *ctx)
+ngx_pid_t ngx_execute(ngx_cycle_t *cycle, ngx_exec_ctx_t *ctx)
 {
-    return ngx_spawn_process(cycle, ngx_exec_proc, ctx, ctx->name,
+    return ngx_spawn_process(cycle, ngx_execute_proc, ctx, ctx->name,
                              NGX_PROCESS_DETACHED);
 }
 
 
-static void ngx_exec_proc(ngx_cycle_t *cycle, void *data)
+static void ngx_execute_proc(ngx_cycle_t *cycle, void *data)
 {
     ngx_exec_ctx_t  *ctx = data;
 
@@ -114,47 +81,6 @@ static void ngx_exec_proc(ngx_cycle_t *c
 }
 
 
-#if 0
-
-void ngx_signal_processes(ngx_cycle_t *cycle)
-{
-    ngx_uint_t  i;
-
-    for (i = 0; i < ngx_last_process; i++) {
-
-        if (ngx_processes[i].signal0 == 0) {
-            continue;
-        }
-
-#if 0
-        if (ngx_processes[i].exited) {
-            if (i != --ngx_last_process) {
-                ngx_processes[i--] = ngx_processes[ngx_last_process];
-            }
-            continue;
-        }
-#endif
-
-        ngx_log_debug2(NGX_LOG_DEBUG_CORE, cycle->log, 0,
-                       "kill (" PID_T_FMT ", %d)" ,
-                       ngx_processes[i].pid, ngx_processes[i].signal0);
-
-        if (kill(ngx_processes[i].pid, ngx_processes[i].signal0) == -1) {
-            ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
-                          "kill(%d, %d) failed",
-                          ngx_processes[i].pid, ngx_processes[i].signal0);
-            continue;
-        }
-
-        if (ngx_processes[i].signal0 != ngx_signal_value(NGX_REOPEN_SIGNAL)) {
-            ngx_processes[i].exiting = 1;
-        }
-    }
-}
-
-#endif
-
-
 void ngx_respawn_processes(ngx_cycle_t *cycle)
 {
     ngx_uint_t  i;
--- a/src/os/unix/ngx_process.h
+++ b/src/os/unix/ngx_process.h
@@ -42,7 +42,7 @@ typedef struct {
 ngx_pid_t ngx_spawn_process(ngx_cycle_t *cycle,
                             ngx_spawn_proc_pt proc, void *data,
                             char *name, ngx_int_t respawn);
-ngx_pid_t ngx_exec(ngx_cycle_t *cycle, ngx_exec_ctx_t *ctx);
+ngx_pid_t ngx_execute(ngx_cycle_t *cycle, ngx_exec_ctx_t *ctx);
 void ngx_respawn_processes(ngx_cycle_t *cycle);
 void ngx_process_get_status(void);
 
--- a/src/os/unix/ngx_process_cycle.c
+++ b/src/os/unix/ngx_process_cycle.c
@@ -95,7 +95,7 @@ void ngx_master_process_cycle(ngx_cycle_
                 if (ngx_modules[i]->init_process) {
                     if (ngx_modules[i]->init_process(cycle) == NGX_ERROR) {
                         /* fatal */
-                        exit(1);
+                        exit(2);
                     }
                 }
             }
@@ -418,7 +418,7 @@ static void ngx_worker_process_cycle(ngx
         if (ngx_modules[i]->init_process) {
             if (ngx_modules[i]->init_process(cycle) == NGX_ERROR) {
                 /* fatal */
-                exit(1);
+                exit(2);
             }
         }
     }
@@ -429,7 +429,7 @@ static void ngx_worker_process_cycle(ngx
 
     if (ngx_init_threads(5, 128 * 1024 * 1024, cycle) == NGX_ERROR) {
         /* fatal */
-        exit(1);
+        exit(2);
     }
 
     for (i = 0; i < 1; i++) {
@@ -437,7 +437,7 @@ static void ngx_worker_process_cycle(ngx
                               cycle, cycle->log) != 0)
         {
             /* fatal */
-            exit(1);
+            exit(2);
         }
     }
 
@@ -494,8 +494,23 @@ int ngx_worker_thread_cycle(void *data)
 {
     ngx_cycle_t *cycle = data;
 
+    ngx_err_t       err;
+    sigset_t        set;
     struct timeval  tv;
 
+    sigfillset(&set);
+    sigdelset(&set, SIGALRM);
+    sigdelset(&set, ngx_signal_value(NGX_TERMINATE_SIGNAL));
+    sigdelset(&set, ngx_signal_value(NGX_SHUTDOWN_SIGNAL));
+
+    err = ngx_thread_sigmask(SIG_BLOCK, &set, NULL);
+    if (err) {
+        ngx_log_error(NGX_LOG_ALERT, cycle->log, err,
+                      ngx_thread_sigmask_n " failed");
+        return 1;
+    }
+
+
     /* STUB */
 
     ngx_log_debug1(NGX_LOG_DEBUG_CORE, ngx_cycle->log, ngx_errno,
--- a/src/os/unix/ngx_thread.h
+++ b/src/os/unix/ngx_thread.h
@@ -36,6 +36,12 @@ typedef volatile struct {
 } ngx_mutex_t;
 
 
+#define ngx_thread_sigmask(how, set, oset)                         \
+            (sigprocmask(how, set, oset) == -1) ? ngx_errno : 0
+
+#define ngx_thread_sigmask_n  "sigprocmask()"
+
+
 extern char    *ngx_freebsd_kern_usrstack;
 extern size_t   ngx_thread_stack_size;
 
@@ -75,6 +81,9 @@ typedef pthread_t  ngx_tid_t;
 #define ngx_gettid()   ((ngx_int_t) pthread_getspecific(0))
 #define ngx_log_tid    ngx_thread_self()
 
+#define ngx_thread_sigmask     pthread_sigmask
+#define ngx_thread_sigmask_n  "pthread_sigmask()"
+
 #endif
 
 
--- a/src/os/win32/ngx_process.h
+++ b/src/os/win32/ngx_process.h
@@ -21,7 +21,7 @@ typedef struct {
 #define NGX_PROCESS_WORKER   2
 
 
-ngx_pid_t ngx_exec(ngx_cycle_t *cycle, ngx_exec_ctx_t *ctx);
+ngx_pid_t ngx_execute(ngx_cycle_t *cycle, ngx_exec_ctx_t *ctx);
 
 
 extern ngx_pid_t     ngx_pid;
--- a/src/os/win32/ngx_win32_config.h
+++ b/src/os/win32/ngx_win32_config.h
@@ -40,10 +40,9 @@
 #define ngx_inline   __inline
 
 
-#if 1
+#ifdef _MSC_VER
 typedef unsigned __int32  uint32_t;
-#else
-/* OWC has not __int32 */
+#else /* __WATCOMC__ */
 typedef unsigned int      uint32_t;
 #endif