Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

End of output occasionally missing with "closeOnExit": "never" #18552

Open
ltrzesniewski opened this issue Feb 10, 2025 · 1 comment
Open

End of output occasionally missing with "closeOnExit": "never" #18552

ltrzesniewski opened this issue Feb 10, 2025 · 1 comment
Labels
Area-Server Down in the muck of API call servicing, interprocess communication, eventing, etc. Issue-Bug It either shouldn't be doing this or needs an investigation. Product-Terminal The new Windows Terminal.

Comments

@ltrzesniewski
Copy link

Windows Terminal version

1.23.10353.0

Windows build number

10.0.22631.0

Other Software

Build one of those (as is more convenient):

using System;

public static class Program
{
    public static void Main()
    {
        for (var i = 0; i <= 20_000; ++i)
            Console.WriteLine($"LINE: {i}");
    }
}
#include <iostream>

int main(int argc, char* argv[])
{
    for (int i = 0; i <= 20000; ++i)
        std::cout << "LINE: " << i << std::endl;

    return 0;
}
fn main() {
    for i in 0..=20_000 {
        println!("LINE: {i}");
    }
}

Steps to reproduce

  • In your default profile settings, set Advanced -> Profile termination behavior to "Never close automatically"
    JSON equivalent:

    "profiles": {
      "defaults": {
        "closeOnExit": "never"
  • Build one of the source codes provided above

  • Double-click on the compiled exe file (do not run it from a shell)

Expected Behavior

The output should always end with the following lines:

LINE: 19995
LINE: 19996
LINE: 19997
LINE: 19998
LINE: 19999
LINE: 20000

[process exited with code 0 (0x00000000)]
You can now close this terminal with Ctrl+D, or press Enter to restart.

Restarting the process by pressing Enter any number of times should not change this outcome.

Actual Behavior

Most of the time, the behavior is as expected: the last line reads LINE: 20000.

However, after restarting the execution several times by pressing Enter, you can end up on an incomplete output, such as:

Image

In the case of the C++ app, I even got the output cut in the middle of a line:

Image

Getting this output may require 10 to 20 attempts, so please be patient. 😅

The problem is not reproducible when looping from a bat file:

@echo off
:loop
ConsoleApp.exe
pause
goto loop

However, a bat file which just runs the exe will reproduce the problem.

@ltrzesniewski ltrzesniewski added Issue-Bug It either shouldn't be doing this or needs an investigation. Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting labels Feb 10, 2025
@carlos-zamora
Copy link
Member

Thanks for filing! (Some psychic debugging from @lhecker) We might be missing a wait call in the VTIO class, which may not wait (on shutdown) to finish flushing to the output pipe. If that's the case, should be an easy fix 😊

@carlos-zamora carlos-zamora added Area-Server Down in the muck of API call servicing, interprocess communication, eventing, etc. Product-Terminal The new Windows Terminal. and removed Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting labels Feb 12, 2025
@carlos-zamora carlos-zamora added this to the Terminal v1.24 milestone Feb 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Server Down in the muck of API call servicing, interprocess communication, eventing, etc. Issue-Bug It either shouldn't be doing this or needs an investigation. Product-Terminal The new Windows Terminal.
Projects
None yet
Development

No branches or pull requests

2 participants