Klaus Demo nginx / 4284648
test premature process termination Igor Sysoev 13 years ago
1 changed file(s) with 19 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
1818 ngx_pid_t
1919 ngx_spawn_process(ngx_cycle_t *cycle, char *name, ngx_int_t respawn)
2020 {
21 u_long rc, n;
21 u_long rc, n, code;
2222 ngx_int_t s;
2323 ngx_pid_t pid;
2424 ngx_exec_ctx_t ctx;
25 HANDLE events[2];
2526 char file[MAX_PATH + 1];
2627
2728 if (respawn >= 0) {
7879 ngx_sprintf(ngx_processes[s].reopen_event, "ngx_%s_reopen_%ul%Z",
7980 name, pid);
8081
81 rc = WaitForSingleObject(ngx_master_process_event, 5000);
82 events[0] = ngx_master_process_event;
83 events[1] = ctx.child;
84
85 rc = WaitForMultipleObjects(2, events, 0, 5000);
8286
8387 ngx_time_update(0, 0);
8488
8589 ngx_log_debug1(NGX_LOG_DEBUG_CORE, cycle->log, 0,
86 "WaitForSingleObject: %ul", rc);
90 "WaitForMultipleObjects: %ul", rc);
8791
8892 switch (rc) {
8993
124128 }
125129
126130 break;
131
132 case WAIT_OBJECT_0 + 1:
133 if (GetExitCodeProcess(ctx.child, &code) == 0) {
134 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
135 "GetExitCodeProcess(%P) failed", pid);
136 }
137
138 ngx_log_error(NGX_LOG_ALERT, cycle->log, 0,
139 "%s process %P exited with code %Xul",
140 name, pid, code);
141
142 goto failed;
127143
128144 case WAIT_TIMEOUT:
129145 ngx_log_error(NGX_LOG_ALERT, cycle->log, 0,