Skip to content

Commit 19fb896

Browse files
angavrilovgitster
authored andcommitted
Windows: Make OpenSSH properly detect tty detachment.
Apparently, CREATE_NO_WINDOW makes the OS tell the process that it has a console, but without actually creating the window. As a result, when git is started from GUI, ssh tries to ask its questions on the invisible console. This patch uses DETACHED_PROCESS instead, which clearly means that the process should be left without a console. The downside is that if the process manually calls AllocConsole, the window will appear. A similar thing might occur if it calls another console executable. Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com> Acked-by: Johannes Sixt <johannes.sixt@telecom.at> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 6331adb commit 19fb896

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

compat/mingw.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -536,12 +536,16 @@ static pid_t mingw_spawnve(const char *cmd, const char **argv, char **env,
536536
* would normally create a console window. But
537537
* since we'll be redirecting std streams, we do
538538
* not need the console.
539+
* It is necessary to use DETACHED_PROCESS
540+
* instead of CREATE_NO_WINDOW to make ssh
541+
* recognize that it has no console.
539542
*/
540-
flags = CREATE_NO_WINDOW;
543+
flags = DETACHED_PROCESS;
541544
} else {
542545
/* There is already a console. If we specified
543-
* CREATE_NO_WINDOW here, too, Windows would
546+
* DETACHED_PROCESS here, too, Windows would
544547
* disassociate the child from the console.
548+
* The same is true for CREATE_NO_WINDOW.
545549
* Go figure!
546550
*/
547551
flags = 0;

0 commit comments

Comments
 (0)