Subject: Re: bug#71853: 29.4; `kill-compilation` does not kill compilation process on Windows

From: Eli Zaretskii <[email-masked]>
Date: Wed, 03 Jul 2024 14:17:06 +0300

> From: Tze Chian Kam <[email-masked]>
> Date: Wed, 3 Jul 2024 13:26:32 +1000
> Cc: [email-masked]
> 
> > > It is a MSYS2 build of Python.
> >
> > So it's not a native Windows executable, I think, and this could well
> > explain what you see.  What does typing the below display?
> >
> >   M-: (w32-application-type (executable-find "python")) RET
> 
> I get "w32-native".

I guess our detection of MSYS applications needs some update?  Can you
show the list of DLLs that your MSYS2 python.exe depends on?  If you
have GNU Binutils installed, the following command should show that:

  objdump -x /path/to/python.exe | fgrep "DLL Name"

> > Also, does setting w32-start-process-share-console to a non-nil value
> > help with interrupting the MSYS2 Python?
> 
> Yes, it does.

So I guess that version of Python is incompatible with the default
method of interrupting sub-processes that Emacs on Windows uses.  It
is known that some programs need such a special handling on Windows.

> > Some kind of buffering problem, I guess?  Try invoking "python -u" to
> > get unbuffered stdout.
> 
> This will work. However, I tested on another C program and the problem
> still occurs, meaning that my Emacs is buffering everything for some
> reason.

It isn't Emacs, it's the OS.  Emacs on Windows uses pipes to talk to
sub-processes, and pipes are buffered.  You need to fflush in your
program.  This is a known issue without any general solution.

So, bottom line, I see no bug here, only known limitations of handling
sub-processes on MS-Windows.