Maximus5 / ConEmu

Customizable Windows terminal with tabs, splits, quake-style, hotkeys and more
https://conemu.github.io/
BSD 3-Clause "New" or "Revised" License
8.5k stars 570 forks source link

Excessive waiting after CRT free process exits #2542

Open grable0 opened 10 months ago

grable0 commented 10 months ago

Versions

ConEmu build: 230724 x64 OS version: Windows 10 x64 1511 Used shell version: ConEmu, cmd / sh

Problem description

Tiny CRT free programs wait for a very long time after process exit. This is most likely the injected ConEmu thread waiting for all threads to exit or waiting for something else maybe. The result is that after a program has returned from its main / mainCRTStartup or just its entrypoint, it waits too long before actually returning control back to the terminal and thrashes the return exit code. Doing an explicit ExitProcess "solves" the problem, but it is rather brute force. This behavior is not in standard cmd.exe, it never waits and always returns the expected exit code even without an ExitProcess.

Steps to reproduce

This is the shortest possible example that will reproduce the waiting, run this in a ConEmu cmd.exe terminal:

  1. echo mov $123,%eax;ret | gcc -xassembler -nostartfiles -
  2. a & echo %errorlevel%
  3. <-- wait for 30 seconds -->

Actual results

0

Expected results

123