Subject: bug#69795: 29.1; cmdproxy.exe exits automatically after executing MSYS2 commands

From: [email-masked]
Date: Sat, 16 Mar 2024 22:14:49 +0900

Eli Zaretskii <[email-masked]> writes:

>> From: [email-masked]
>> Cc: [email-masked]
>> Date: Sat, 16 Mar 2024 12:52:19 +0900
>> 
>> > So let's start from the beginning: can you show a recipe, starting
>> > from "emacs -Q", where you invoke GDB from Emacs, and cmdproxy (or
>> > some other sub-process) exits?
>> 
>> I found that setting PATH make the difference.
>> Start emacs -Q, type 'M-x shell RET',
>> and input following command lines.
>>   set PATH=c:\msys64\mingw64\bin\;c:\msys64\usr\bin\;%PATH%
>>   c:\msys64\mingw64\bin\gdb.exe
>>   q
>> Then cmdproxy.exe exits automatically.
>
> Please show the value of PATH after "set PATH" above.  Like this:
>
>   c:\tmp>set PATH

Before setting PATH, the value is:
  C:\ImageMagick;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Users\user\AppData\Local\Programs\Python\Python310\Scripts\;C:\Users\user\AppData\Local\Programs\Python\Python310\;C:\Users\user\AppData\Local\Microsoft\WindowsApps;
Then removing directories other than C:\WINDOWS or descendants:
  C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;
Here is a log with the PATH value above.

Microsoft Windows [Version 10.0.19045.4170]
(c) Microsoft Corporation. All rights reserved.

c:\tmp>set PATH=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;
set PATH=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;

c:\tmp>set PATH=c:\msys64\mingw64\bin\;c:\msys64\usr\bin\;%PATH%
set PATH=c:\msys64\mingw64\bin\;c:\msys64\usr\bin\;%PATH%

c:\tmp>set PATH
set PATH
PATH=c:\msys64\mingw64\bin\;c:\msys64\usr\bin\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC

c:\tmp>c:\msys64\mingw64\bin\gdb.exe
c:\msys64\mingw64\bin\gdb.exe
GNU gdb (GDB) 13.2
Copyright (C) 2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-w64-mingw32".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word".
(gdb) q

c:\tmp>
Process shell finished

> (I have a very different MinGW directory tree here, but I tried to do
> something equivalent to what you do above, and couldn't reproduce it:
> I get placed at the cmd.exe prompt, as expected.)
>
> And once again: it is not cmdproxy that exits, it's cmd.exe.  cmdproxy
> will not exit until the process it started, in this case cmd.exe,
> exits.
>
> Btw, why do you end each element of PATH with a backslash '\' ?  This
> is not required.  (I don't think it's part of your problem, but
> still.)

I often use 'C-x C-f' to input a pathname, and 'C-w'(copy) 'C-g'(quit)
in minibuffer. '/' at the last of directory names are automatically
added by completion. Then I replaced '/' with '\'. I have forgotten
that the last '\' is not required (and not inhibited).