Skip to content

Ctrl+C doesn't work as expected with SSH Remoting #2321

@PaulHigin

Description

@PaulHigin

In PowerShell Ctrl+C should stop a running command. But in an SSH interactive remote session Ctrl+C terminates the SSH process and closes the session. This behavior is the same for both Windows and Linux clients.

This is happening because both PowerShell and SSH processes are attached to the console and so they both get the SIGINT signal. PowerShell sends a PSRP stop signal over the channel as expected but the SSH process also handles the signal and terminates the process which closes the remote session.

Steps to reproduce

PS> Enter-PSSession -HostName <hostName> -UserName <userName>
[<hostName>]: PS > 1..100 % { sleep 1; "Output $_" }
Output 1
Output 2
# While script is running type Ctrl+C to stop it

Expected behavior

Running command stops and remote session prompt is displayed.

Actual behavior

Session is ended with error:

System.IO.IOException: Pipe is broken

Also the exception is unhandled causing PowerShell process to crash.

Environment data

Name                           Value
----                           -----
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
SerializationVersion           1.1.0.1
PSRemotingProtocolVersion      2.3
BuildVersion                   3.0.0.0
WSManStackVersion              3.0
PSVersion                      6.0.0-alpha
CLRVersion
GitCommitId                    v6.0.0-alpha.10-8-gdd2394b1e6088f6c82054f5cae5520e532010fd4-dirty
PSEdition                      Core

Metadata

Metadata

Assignees

Labels

Issue-BugIssue has been identified as a bug in the productOS-LinuxOS-macOSResolution-FixedThe issue is fixed.WG-RemotingPSRP issues with any transport layer

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions