First of all, I'm on Windows 10, using the MINGW64 MSYS2 environment, so this issue might be specific to MinGW. Note: While I'm using a UCRT build of Emacs to generate this report, the problem is present in the MinGW GCC build as well. Emacs has some weird behaviour regarding subprocess handling (?) when compiled with "-D_FORTIFY_SOURCE=1". Setting the value to 2 causes the same issue, I haven't tested setting it to 3. I believe this is the why the MSYS2 Emacs builds have been broken for a while now: https://github.com/msys2/MINGW-packages/issues/16190 https://github.com/msys2/MINGW-packages/issues/16375 https://github.com/msys2/MINGW-packages/issues/16413 I've managed to reproduce the issue when building from the emacs sources as follows: git clone https://git.savannah.gnu.org/git/emacs.git cd emacs git checkout emacs-28.2 ./autogen.sh export CFLAGS='-g3 -O2 -gdwarf-2 -Wp,-D_FORTIFY_SOURCE=1' ./configure make "-g3 -O2 -gdwarf-2" were the default compilation options. The build terminates fine but the executable has problems. Executing "dir" via async-shell-command doesn't terminate properly, for example: ./src/emacs -Q --eval '(async-shell-command "dir")' Trying to close the window results in Emacs saying there are active processes, which there shouldn't be. Other symptoms are described in the linked Github issues. In the example above, I built Emacs from the emacs-28.2 tag, but I also managed to reproduce the issue in the emacs-28, emacs-29 and master branches. In GNU Emacs 28.2 (build 2, x86_64-w64-mingw32) of 2023-05-27 built on ZUERILL Repository revision: f31980c83aee3840ee90688447198a37a14f7aaf Repository branch: emacs-28.2 Windowing system distributor 'Microsoft Corp.', version 10.0.19044 System Description: Microsoft Windows 10 Pro (v10.0.2009.19044.2965) Configured using: 'configure --prefix=/ucrt64 --host=x86_64-w64-mingw32 --build=x86_64-w64-mingw32 --with-modules --without-dbus --without-compress-install --with-native-compilation 'CFLAGS=-march=nocona -msahf -mtune=generic -O2 -pipe -fstack-protector-strong' CPPFLAGS=-D__USE_MINGW_ANSI_STDIO=1 'LDFLAGS=-pipe -lpthread'' Configured features: ACL GIF GMP GNUTLS HARFBUZZ JPEG JSON LCMS2 LIBXML2 MODULES NATIVE_COMP NOTIFY W32NOTIFY PDUMPER PNG RSVG SOUND THREADS TIFF TOOLKIT_SCROLL_BARS XPM ZLIB Important settings: value of $LANG: en_GB locale-coding-system: cp1252 Major mode: Lisp Interaction Minor modes in effect: display-line-numbers-mode: t override-global-mode: t delete-selection-mode: t tabbar-mwheel-mode: t tabbar-mode: t global-so-long-mode: t global-flycheck-mode: t flycheck-mode: t cua-mode: t company-tng-mode: t tooltip-mode: t global-eldoc-mode: t eldoc-mode: t show-paren-mode: t electric-indent-mode: t mouse-wheel-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t size-indication-mode: t column-number-mode: t line-number-mode: t transient-mark-mode: t Load-path shadows: ~/.lisp/load/vhdl-mode hides c:/msys64/ucrt64/share/emacs/28.2/lisp/progmodes/vhdl-mode Features: (shadow sort mail-extr emacsbug message rmc puny dired dired-loaddefs rfc822 mml mml-sec epa derived epg rfc6068 epg-config gnus-util rmail rmail-loaddefs time-date mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils display-line-numbers cl-extra use-package use-package-ensure use-package-delight use-package-diminish use-package-bind-key bind-key use-package-core server delsel tabbar easy-mmode grep compile text-property-search comint ring so-long flycheck ansi-color find-func help-mode rx dash cua-base company-tng company edmacro kmacro pcase cus-load tex-site info package browse-url url url-proxy url-privacy url-expand url-methods url-history url-cookie url-domsuf url-util mailcap url-handlers url-parse auth-source cl-seq eieio eieio-core cl-macs eieio-loaddefs password-cache json subr-x map url-vars seq byte-opt gv bytecomp byte-compile cconv cl-loaddefs cl-lib iso-transl tooltip eldoc paren electric uniquify ediff-hook vc-hooks lisp-float-type elisp-mode mwheel dos-w32 ls-lisp disp-table term/w32-win w32-win w32-vars term/common-win tool-bar dnd fontset image regexp-opt fringe tabulated-list replace newcomment text-mode lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow isearch easymenu timer select scroll-bar mouse jit-lock font-lock syntax font-core term/tty-colors frame minibuffer cl-generic cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese composite emoji-zwj charscript charprop case-table epa-hook jka-cmpr-hook help simple abbrev obarray cl-preloaded nadvice button loaddefs faces cus-face macroexp files window text-properties overlay sha1 md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote threads w32notify w32 lcms2 multi-tty make-network-process native-compile emacs) Memory information: ((conses 16 161207 53896) (symbols 48 13207 112) (strings 32 43518 8562) (string-bytes 1 1529452) (vectors 16 23546) (vector-slots 8 437343 90008) (floats 8 73 206) (intervals 56 299 290) (buffers 992 11))