diff --git a/contrib/win32/win32compat/w32fd.c b/contrib/win32/win32compat/w32fd.c index 080714242..35a5b9646 100644 --- a/contrib/win32/win32compat/w32fd.c +++ b/contrib/win32/win32compat/w32fd.c @@ -88,6 +88,19 @@ fd_table_initialize() { struct w32_io *pio; HANDLE wh; + char *stdio_mode_env; + int stdio_mode = NONSOCK_SYNC_FD; + + stdio_mode_env = getenv("OPENSSH_STDIO_MODE"); + if (stdio_mode_env != NULL) { + if (strcmp(stdio_mode_env, "sock") == 0) + stdio_mode = SOCK_FD; + else if (strcmp(stdio_mode_env, "nonsock") == 0) + stdio_mode = NONSOCK_FD; + else if (strcmp(stdio_mode_env, "nonsock_sync") == 0) + stdio_mode = NONSOCK_SYNC_FD; + } + /* table entries representing std in, out and error*/ DWORD wh_index[] = { STD_INPUT_HANDLE , STD_OUTPUT_HANDLE , STD_ERROR_HANDLE }; int fd_num = 0; @@ -104,7 +117,7 @@ fd_table_initialize() return -1; } memset(pio, 0, sizeof(struct w32_io)); - pio->type = NONSOCK_SYNC_FD; + pio->type = stdio_mode; pio->handle = wh; fd_table_set(pio, fd_num); }