Skip to content
This repository has been archived by the owner on May 4, 2018. It is now read-only.

Add UV_PROCESS_WINDOWS_HIDE to avoid consoles on Windows #627

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion include/uv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1314,7 +1314,12 @@ enum uv_process_flags {
* parent's event loop alive unless the parent process calls uv_unref() on
* the child's process handle.
*/
UV_PROCESS_DETACHED = (1 << 3)
UV_PROCESS_DETACHED = (1 << 3),
/*
* Hide the subprocess console window that would normally be created. This
* option is only meaningful on Windows systems. On unix it is silently ignored.
*/
UV_PROCESS_WINDOWS_HIDE = (1 << 4)
};

/*
Expand Down
11 changes: 9 additions & 2 deletions src/win/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,8 @@ int uv_spawn(uv_loop_t* loop, uv_process_t* process,
}

assert(options.file != NULL);
assert(!(options.flags & ~(UV_PROCESS_WINDOWS_VERBATIM_ARGUMENTS |
assert(!(options.flags & ~(UV_PROCESS_WINDOWS_HIDE |
UV_PROCESS_WINDOWS_VERBATIM_ARGUMENTS |
UV_PROCESS_DETACHED |
UV_PROCESS_SETGID |
UV_PROCESS_SETUID)));
Expand Down Expand Up @@ -872,7 +873,13 @@ int uv_spawn(uv_loop_t* loop, uv_process_t* process,
startup.lpReserved = NULL;
startup.lpDesktop = NULL;
startup.lpTitle = NULL;
startup.dwFlags = STARTF_USESTDHANDLES;
startup.dwFlags = STARTF_USESTDHANDLES|STARTF_USESHOWWINDOW;
if (options.flags & UV_PROCESS_WINDOWS_HIDE) {
/* Use SW_HIDE to avoid any potential process window */
startup.wShowWindow = SW_HIDE;
} else {
startup.wShowWindow = SW_SHOWDEFAULT;
}
startup.cbReserved2 = uv__stdio_size(process->child_stdio_buffer);
startup.lpReserved2 = (BYTE*) process->child_stdio_buffer;
startup.hStdInput = uv__stdio_handle(process->child_stdio_buffer, 0);
Expand Down