@@ -152,9 +152,8 @@ lws_spawn_reap(struct lws_spawn_piped *lsp)
152152 lws_spawn_resource_us_t res = { };
153153 void * opaque = lsp -> info .opaque ;
154154 lsp_cb_t cb = lsp -> info .reap_cb ;
155- struct _lws_siginfo_t lsi ;
156155 PROCESS_MEMORY_COUNTERS pmc ;
157- // IO_COUNTERS ic ;
156+ struct _lws_siginfo_t lsi ;
158157 ULARGE_INTEGER uli ;
159158 FILETIME ftk , ftu ;
160159 DWORD ex ;
@@ -163,7 +162,7 @@ lws_spawn_reap(struct lws_spawn_piped *lsp)
163162 return 0 ;
164163
165164 if (!GetExitCodeProcess (lsp -> child_pid , & ex )) {
166- lwsl_notice ("%s: GetExitCodeProcess failed\n" , __func__ );
165+ lwsl_notice ("%s: GetExitCodeProcess failed, GetLastError: 0x%lx \n" , __func__ , ( unsigned long ) GetLastError () );
167166 return 0 ;
168167 }
169168
@@ -214,21 +213,21 @@ lws_spawn_reap(struct lws_spawn_piped *lsp)
214213 uli .LowPart = ftu .dwLowDateTime ;
215214 uli .HighPart = ftu .dwHighDateTime ;
216215 lsp -> res .us_cpu_user = uli .QuadPart / 10 ;
216+ if (lsp -> info .res )
217+ lsp -> info .res -> us_cpu_user = lsp -> res .us_cpu_user ;
217218
218219 uli .LowPart = ftk .dwLowDateTime ;
219220 uli .HighPart = ftk .dwHighDateTime ;
220221 lsp -> res .us_cpu_sys = uli .QuadPart / 10 ;
222+ if (lsp -> info .res )
223+ lsp -> info .res -> us_cpu_sys = lsp -> res .us_cpu_sys ;
221224 }
222225
223- if (GetProcessMemoryInfo (lsp -> child_pid , & pmc , sizeof (pmc )))
226+ if (GetProcessMemoryInfo (lsp -> child_pid , & pmc , sizeof (pmc ))) {
224227 lsp -> res .peak_mem_rss = pmc .PeakWorkingSetSize ;
225-
226- /*
227- if (GetProcessIoCounters(lsp->child_pid, &ic)) {
228- lsp->res.io_r_bytes = ic.ReadTransferCount;
229- lsp->res.io_w_bytes = ic.WriteTransferCount;
228+ if (lsp -> info .res )
229+ lsp -> info .res -> peak_mem_rss = lsp -> res .peak_mem_rss ;
230230 }
231- */
232231
233232 lsi .retcode = 0x10000 | (int )ex ;
234233 lwsl_notice ("%s: process exit 0x%x\n" , __func__ , lsi .retcode );
@@ -267,7 +266,10 @@ lws_spawn_piped_kill_child_process(struct lws_spawn_piped *lsp)
267266 return 0 ;
268267
269268 lwsl_warn ("%s: calling TerminateProcess on child pid\n" , __func__ );
270- TerminateProcess (lsp -> child_pid , 252 );
269+ if (!TerminateProcess (lsp -> child_pid , 252 )) {
270+ lwsl_warn ("%s: TerminateProcess failed: 0x%lx\n" , __func__ , (unsigned long )GetLastError ());
271+ return 0 ;
272+ }
271273 lws_spawn_reap (lsp );
272274
273275 /* that may have invalidated lsp */
@@ -534,6 +536,7 @@ lws_spawn_piped(const struct lws_spawn_piped_info *i)
534536 }
535537
536538 lsp -> child_pid = pi .hProcess ;
539+ CloseHandle (pi .hThread );
537540
538541 lwsl_notice ("%s: lsp %p spawned PID %d\n" , __func__ , lsp , lsp -> child_pid );
539542
0 commit comments