Mercurial > hg > nginx-quic
comparison src/os/win32/ngx_process.c @ 2909:3f287b615408
test premature process termination
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Tue, 02 Jun 2009 14:26:59 +0000 |
parents | 1983932b8075 |
children | d82993af1da0 |
comparison
equal
deleted
inserted
replaced
2908:234a8248812c | 2909:3f287b615408 |
---|---|
17 | 17 |
18 | 18 |
19 ngx_pid_t | 19 ngx_pid_t |
20 ngx_spawn_process(ngx_cycle_t *cycle, char *name, ngx_int_t respawn) | 20 ngx_spawn_process(ngx_cycle_t *cycle, char *name, ngx_int_t respawn) |
21 { | 21 { |
22 u_long rc, n; | 22 u_long rc, n, code; |
23 ngx_int_t s; | 23 ngx_int_t s; |
24 ngx_pid_t pid; | 24 ngx_pid_t pid; |
25 ngx_exec_ctx_t ctx; | 25 ngx_exec_ctx_t ctx; |
26 HANDLE events[2]; | |
26 char file[MAX_PATH + 1]; | 27 char file[MAX_PATH + 1]; |
27 | 28 |
28 if (respawn >= 0) { | 29 if (respawn >= 0) { |
29 s = respawn; | 30 s = respawn; |
30 | 31 |
77 ngx_sprintf(ngx_processes[s].term_event, "ngx_%s_term_%ul%Z", name, pid); | 78 ngx_sprintf(ngx_processes[s].term_event, "ngx_%s_term_%ul%Z", name, pid); |
78 ngx_sprintf(ngx_processes[s].quit_event, "ngx_%s_quit_%ul%Z", name, pid); | 79 ngx_sprintf(ngx_processes[s].quit_event, "ngx_%s_quit_%ul%Z", name, pid); |
79 ngx_sprintf(ngx_processes[s].reopen_event, "ngx_%s_reopen_%ul%Z", | 80 ngx_sprintf(ngx_processes[s].reopen_event, "ngx_%s_reopen_%ul%Z", |
80 name, pid); | 81 name, pid); |
81 | 82 |
82 rc = WaitForSingleObject(ngx_master_process_event, 5000); | 83 events[0] = ngx_master_process_event; |
84 events[1] = ctx.child; | |
85 | |
86 rc = WaitForMultipleObjects(2, events, 0, 5000); | |
83 | 87 |
84 ngx_time_update(0, 0); | 88 ngx_time_update(0, 0); |
85 | 89 |
86 ngx_log_debug1(NGX_LOG_DEBUG_CORE, cycle->log, 0, | 90 ngx_log_debug1(NGX_LOG_DEBUG_CORE, cycle->log, 0, |
87 "WaitForSingleObject: %ul", rc); | 91 "WaitForMultipleObjects: %ul", rc); |
88 | 92 |
89 switch (rc) { | 93 switch (rc) { |
90 | 94 |
91 case WAIT_OBJECT_0: | 95 case WAIT_OBJECT_0: |
92 | 96 |
123 ngx_master_process_event_name); | 127 ngx_master_process_event_name); |
124 goto failed; | 128 goto failed; |
125 } | 129 } |
126 | 130 |
127 break; | 131 break; |
132 | |
133 case WAIT_OBJECT_0 + 1: | |
134 if (GetExitCodeProcess(ctx.child, &code) == 0) { | |
135 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, | |
136 "GetExitCodeProcess(%P) failed", pid); | |
137 } | |
138 | |
139 ngx_log_error(NGX_LOG_ALERT, cycle->log, 0, | |
140 "%s process %P exited with code %Xul", | |
141 name, pid, code); | |
142 | |
143 goto failed; | |
128 | 144 |
129 case WAIT_TIMEOUT: | 145 case WAIT_TIMEOUT: |
130 ngx_log_error(NGX_LOG_ALERT, cycle->log, 0, | 146 ngx_log_error(NGX_LOG_ALERT, cycle->log, 0, |
131 "the event \"%s\" was not signaled for 5s", | 147 "the event \"%s\" was not signaled for 5s", |
132 ngx_master_process_event_name); | 148 ngx_master_process_event_name); |