{"thread":{"id":"16132","subject":"[PATCH (MINGW) Resend] Windows: Make OpenSSH properly detect tty detachment.","startedAt":"2008-11-02T17:11:13Z","lastAt":"2008-11-06T17:21:20Z","messageCount":4,"participants":["Alexander Gavrilov","Johannes Sixt","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"94672","messageId":"200811022011.13970.angavrilov@gmail.com","threadId":"16132","inReplyTo":null,"subject":"[PATCH (MINGW) Resend] Windows: Make OpenSSH properly detect tty detachment.","fromName":"Alexander Gavrilov","fromEmail":"angavrilov@gmail.com","sentAt":"2008-11-02T17:11:13Z","receivedAt":"2008-11-02T17:11:13Z","isPatch":true,"sender":{"key":"angavrilov@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42666?v=4"},"body":"Apparently, CREATE_NO_WINDOW makes the OS tell the process\nthat it has a console, but without actually creating the\nwindow. As a result, when git is started from GUI, ssh\ntries to ask its questions on the invisible console.\n\nThis patch uses DETACHED_PROCESS instead, which clearly\nmeans that the process should be left without a console.\nThe downside is that if the process manually calls\nAllocConsole, the window will appear. A similar thing\nmight occur if it calls another console executable.\n\nSigned-off-by: Alexander Gavrilov <angavrilov@gmail.com>\nAcked-by: Johannes Sixt <johannes.sixt@telecom.at>\n---\n\n\tThis patch appears to have been overlooked, so I\tresend\n\tit just in case. It fixes a long standing problem in msysgit.\n\n\t-- Alexander\n\n compat/mingw.c |    8 ++++++--\n 1 files changed, 6 insertions(+), 2 deletions(-)\n\ndiff --git a/compat/mingw.c b/compat/mingw.c\nindex 1e29b88..b6fcf69 100644\n--- a/compat/mingw.c\n+++ b/compat/mingw.c\n@@ -586,12 +586,16 @@ static pid_t mingw_spawnve(const char *cmd, const char **argv, char **env,\n \t\t * would normally create a console window. But\n \t\t * since we'll be redirecting std streams, we do\n \t\t * not need the console.\n+\t\t * It is necessary to use DETACHED_PROCESS\n+\t\t * instead of CREATE_NO_WINDOW to make ssh\n+\t\t * recognize that it has no console.\n \t\t */\n-\t\tflags = CREATE_NO_WINDOW;\n+\t\tflags = DETACHED_PROCESS;\n \t} else {\n \t\t/* There is already a console. If we specified\n-\t\t * CREATE_NO_WINDOW here, too, Windows would\n+\t\t * DETACHED_PROCESS here, too, Windows would\n \t\t * disassociate the child from the console.\n+\t\t * The same is true for CREATE_NO_WINDOW.\n \t\t * Go figure!\n \t\t */\n \t\tflags = 0;\n-- \n1.6.0.2.1256.ga12f0\n"},{"id":"95029","messageId":"49129E47.4080209@viscovery.net","threadId":"16132","inReplyTo":"200811022011.13970.angavrilov@gmail.com","subject":"Re: [PATCH (MINGW) Resend] Windows: Make OpenSSH properly detect tty detachment.","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2008-11-06T07:35:35Z","receivedAt":"2008-11-06T07:35:35Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Alexander Gavrilov schrieb:\n> Apparently, CREATE_NO_WINDOW makes the OS tell the process\n> that it has a console, but without actually creating the\n> window. As a result, when git is started from GUI, ssh\n> tries to ask its questions on the invisible console.\n> \n> This patch uses DETACHED_PROCESS instead, which clearly\n> means that the process should be left without a console.\n> The downside is that if the process manually calls\n> AllocConsole, the window will appear. A similar thing\n> might occur if it calls another console executable.\n\nThe latest \"What's cooking in git.git\" report still doesn't mention this\npatch. The reason might be that you mention some scary downsides in this\nparagraph. I think you should either not mention the downsides, or\ndescribe further why they do not make a difference in our case:\n\n- We never call AllocConsole(). If some third-party program calls it, then\nit gets what it requested. (But, yes, the behavior would indeed be\ndifferent from what it used to be.)\n\n- There are two possible circumstances when another console executable is\ncalled:\n\n  * A program that has no console - e.g. git-gui - runs a git process.\nThen we are entering the \"then\" branch, and the new process is started\nwith DETACH_PROCESS. No new console window appears.\n\n  * A program that already has a console runs a git process. Then we are\nentering the \"else\" branch, and we do not change the process flags nor are\nwe requesting a new console. No new console window appears.\n\nI'm using this patch since weeks without noticing any downsides.\n\n-- Hannes\n\n> \n> Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>\n> Acked-by: Johannes Sixt <johannes.sixt@telecom.at>\n> ---\n> \n> \tThis patch appears to have been overlooked, so I\tresend\n> \tit just in case. It fixes a long standing problem in msysgit.\n> \n> \t-- Alexander\n> \n>  compat/mingw.c |    8 ++++++--\n>  1 files changed, 6 insertions(+), 2 deletions(-)\n> \n> diff --git a/compat/mingw.c b/compat/mingw.c\n> index 1e29b88..b6fcf69 100644\n> --- a/compat/mingw.c\n> +++ b/compat/mingw.c\n> @@ -586,12 +586,16 @@ static pid_t mingw_spawnve(const char *cmd, const char **argv, char **env,\n>  \t\t * would normally create a console window. But\n>  \t\t * since we'll be redirecting std streams, we do\n>  \t\t * not need the console.\n> +\t\t * It is necessary to use DETACHED_PROCESS\n> +\t\t * instead of CREATE_NO_WINDOW to make ssh\n> +\t\t * recognize that it has no console.\n>  \t\t */\n> -\t\tflags = CREATE_NO_WINDOW;\n> +\t\tflags = DETACHED_PROCESS;\n>  \t} else {\n>  \t\t/* There is already a console. If we specified\n> -\t\t * CREATE_NO_WINDOW here, too, Windows would\n> +\t\t * DETACHED_PROCESS here, too, Windows would\n>  \t\t * disassociate the child from the console.\n> +\t\t * The same is true for CREATE_NO_WINDOW.\n>  \t\t * Go figure!\n>  \t\t */\n>  \t\tflags = 0;\n"},{"id":"95059","messageId":"7vvdv0iyl2.fsf@gitster.siamese.dyndns.org","threadId":"16132","inReplyTo":"49129E47.4080209@viscovery.net","subject":"Re: [PATCH (MINGW) Resend] Windows: Make OpenSSH properly detect tty detachment.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-11-06T16:55:05Z","receivedAt":"2008-11-06T16:55:05Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Sixt <j.sixt@viscovery.net> writes:\n\n> The latest \"What's cooking in git.git\" report still doesn't mention this\n> patch. The reason might be ...\n\nSorry, my mistake.\n\n>> Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>\n>> Acked-by: Johannes Sixt <johannes.sixt@telecom.at>\n>> ---\n>> \n>> \tThis patch appears to have been overlooked,\n\nIndeed.  It was lost in the noise because it was marked MinGW and I failed\nto see your Ack.\n\nDo people build and test MinGW port out of my 'next'?  If so, I'll queue\nthis on its own topic branch and have it go through the usual \"cook then\ngraduate\" cycle.  Otherwise, I'll apply this directly on top of 'master'.\n\nThanks.\n"},{"id":"95064","messageId":"49132790.9080105@viscovery.net","threadId":"16132","inReplyTo":"7vvdv0iyl2.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH (MINGW) Resend] Windows: Make OpenSSH properly detect tty detachment.","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2008-11-06T17:21:20Z","receivedAt":"2008-11-06T17:21:20Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Junio C Hamano schrieb:\n> Do people build and test MinGW port out of my 'next'?  If so, I'll queue\n> this on its own topic branch and have it go through the usual \"cook then\n> graduate\" cycle.  Otherwise, I'll apply this directly on top of 'master'.\n\nMy own build is on top of your 'master', and I've cooked this patch to\ndeath there already, so I don't think it needs another cycle. ;)\n\n-- Hannes\n"}]}