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

From: [email-masked]
Date: Fri, 15 Mar 2024 00:56:02 +0900

Eli Zaretskii <[email-masked]> writes:

>> From: [email-masked]
>> Date: Thu, 14 Mar 2024 19:55:27 +0900
>> 
>> 
>> I have installed MSYS2 commands.
>> When executing some MSYS2 commands in shell-mode buffer,
>> cmdproxy.exe exits unintentionally.
>> 
>> The log below has two prompt strings('c:\tmp>'), but the second one is
>> displayed with "Process shell finished" simultaneously.
>
> This is not an Emacs bug.  MSYS2 programs are subtly incompatible with
> the native Windows build of Emacs, and some of those incompatibilities
> are indeed in the area of running subprocesses and capturing their
> output.  In particular, cmdproxy tries hard to accommodate Cygwin and
> MSYS programs, but is rarely used with them, and no one stepped
> forward to maintain such a combination and keep in good working order
> as Cygwin and MSYS evolve.  Another bunch of problems is in the area
> of text encoding and decoding: Cygwin and MSYS use UTF-8 by default,
> something native Windows doesn't yet support well enough.  It is
> possible that the problem you show was due to this latter issue, since
> 'ls' displays a non-ASCII file name there.

Replacing 'ls -ld .' with 'ls -d .', which outputs only '.',
cmdproxy.exe exits, too.
Replacing 'ls -d .' with 'ls -d . < nul' does not make cmdproxy.exe exit.

> If you want to run MSYS or Cygwin programs from Emacs, my suggestion
> is to use the Cygwin build of Emacs.  There are two configurations for
> that: either use the Cygwin X server, or use the w32 "toolkit"; the
> latter possibility has the look-and-feel very similar to the native
> Windows build, so maybe you will prefer it.
>
> Other than that, running MSYS programs from a native build of Emacs
> should be considered "not really supported".

Is calling MSYS2 commands from #'start-process or #'call-process
not recommended?

I only needed gdb, another binary will do. But I do not know where to
get a reliable gdb binary run with emacs shell-mode.