Skip to content

Commit

Permalink
windows: Always initialize the uv_process_t
Browse files Browse the repository at this point in the history
The unix implementation of uv_spawn always starts out with a
uv__handle_init, but the windows implementation sometimes bails out early
before calling uv__handle_init. This means that uv_close on a failed
uv_spawn will always succeed on unix but sometimes fail on windows.

This commit lifts the initialization of the uv_process_t above all of the
error checking to ensure that uv_close will always work when uv_spawn
returns an error.
  • Loading branch information
alexcrichton committed Feb 16, 2014
1 parent a284b90 commit cf9fbc3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/win/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,9 @@ int uv_spawn(uv_loop_t* loop,
PROCESS_INFORMATION info;
DWORD process_flags;

uv_process_init(loop, process);
process->exit_cb = options->exit_cb;

if (options->flags & (UV_PROCESS_SETGID | UV_PROCESS_SETUID)) {
return UV_ENOTSUP;
}
Expand All @@ -827,9 +830,6 @@ int uv_spawn(uv_loop_t* loop,
UV_PROCESS_WINDOWS_HIDE |
UV_PROCESS_WINDOWS_VERBATIM_ARGUMENTS)));

uv_process_init(loop, process);
process->exit_cb = options->exit_cb;

err = uv_utf8_to_utf16_alloc(options->file, &application);
if (err)
goto done;
Expand Down

0 comments on commit cf9fbc3

Please sign in to comment.