Skip to content

Console output gets messed up after GetCursorPosition is called, if application has been started with "dotnet run". #75073

Description

@perjahn

Description

  • In Linux, output of console gets messed up after abrupt exit, if application has called Console.GetCursorPosition.
  • Reproduce: Create a console app that is calling Console.GetCursorPosition and then waits in a loop. Start application with "dotnet run", and then break the application using Ctrl+C.
  • After the .net/c# application has quit, text output in terminal gets disabled.

Configuration

  • Using dotnet 6.0.400.
  • Native Kubuntu 22.04 and Docker (mcr.microsoft.com/dotnet/sdk) on both Macos and Linux.
  • Architecture x64 and arm64.
  • Appear to be specific to linux, b/c it works well on native terminals in Macos (arm64).

Regression

Haven't tested with older dotnet versions than 6.0, but 6.0.200 has the same problem.

Example application (that disables console output after Ctrl+C)

class Program
{
    public static void Main()
    {
        var pos = System.Console.GetCursorPosition();
        while (true) { }
    }
}

Another example application (that also disables console output after exit)

class Program
{
    public static void Main()
    {
        var pos = System.Console.GetCursorPosition();
        System.Environment.FailFast(string.Empty);
    }
}

Project file

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net6.0</TargetFramework>
  </PropertyGroup>
</Project>

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions