.
This commit is contained in:
parent
7026872240
commit
144312744c
2 changed files with 28 additions and 15 deletions
|
|
@ -789,7 +789,7 @@ oshandle_t os_run_cmd_async(arena_t scratch, os_cmd_t *cmd, os_cmd_options_t *op
|
|||
|
||||
if (options && options->in) {
|
||||
CreatePipe(&hstdin_read, &hstdin_write, &sa_attr, 0);
|
||||
options->in->data = (uptr)hstdin_read;
|
||||
options->in->data = (uptr)hstdin_write;
|
||||
SetHandleInformation(hstdin_write, HANDLE_FLAG_INHERIT, 0);
|
||||
}
|
||||
|
||||
|
|
@ -839,17 +839,11 @@ oshandle_t os_run_cmd_async(arena_t scratch, os_cmd_t *cmd, os_cmd_options_t *op
|
|||
&proc_info
|
||||
);
|
||||
|
||||
if (hstdout_write) {
|
||||
CloseHandle(hstdout_write);
|
||||
}
|
||||
#define CLOSE_IF(x) if (x) CloseHandle(x)
|
||||
|
||||
if (hstderr_write) {
|
||||
CloseHandle(hstderr_write);
|
||||
}
|
||||
|
||||
if (hstdin_read) {
|
||||
CloseHandle(hstdin_read);
|
||||
}
|
||||
CLOSE_IF(hstdout_write);
|
||||
CLOSE_IF(hstderr_write);
|
||||
CLOSE_IF(hstdin_read);
|
||||
|
||||
if (env) {
|
||||
FreeEnvironmentStringsW(env);
|
||||
|
|
@ -858,10 +852,13 @@ oshandle_t os_run_cmd_async(arena_t scratch, os_cmd_t *cmd, os_cmd_options_t *op
|
|||
|
||||
if (!success && !quiet) {
|
||||
err("couldn't create process (%v): %v", cmd_str, os_get_error_string(os_get_last_error()));
|
||||
CLOSE_IF(hstdout_read);
|
||||
CLOSE_IF(hstderr_read);
|
||||
CLOSE_IF(hstdin_write);
|
||||
return os_handle_zero();
|
||||
}
|
||||
|
||||
CloseHandle(proc_info.hThread);
|
||||
CLOSE_IF(proc_info.hThread);
|
||||
|
||||
return (oshandle_t) {
|
||||
.data = (uptr)proc_info.hProcess
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue