k blog.kenaro.com
← All articles

PowerShell on Linux / Debian 11 - Ctrl+C not working

· Ingo Karstein

I just found out that on my Debian 11 VM in PowerShell the key combination Ctrl+C does not work.

The script is not terminated by this, unlike expected.

I added the following code and now it works.

add-type -typedefinition @"
using System;
using System.IO;

public class CtrlCHandler
{
	public static void Main()
	{
		System.Console.CancelKeyPress += (s,e) => System.Diagnostics.Process.GetCurrentProcess().Kill();
	}
}
	
"@

[CtrlCHandler]::Main()

0 comments

Leave a comment

Your comment is reviewed before it appears. Your name is shown with the comment; your email is required for moderation but never published.