PowerShell / PowerShell/Win32-OpenSSH

Nested SSH process hanging when launched with pipes

Open
#1,748 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
No language data
Stars
8.3k
Forks
819
PR merge metrics
No merged PRs in 30d

Description

"OpenSSH for Windows" version
OpenSSH_for_Windows_8.1p1

Server OperatingSystem
Windows 10.0.17763

Client OperatingSystem
Windows 10.0.17763

What is failing
Applications/scripts being run through SSH that then launch an SSH process through CreateProcess, subprocess, Popen, etc. using pipes fail to complete as expected. This is occurring in both a C++ application and a Python script. Attached is my Python script for recreating. The script is being launched with the following line:

ssh localhost python C:\Work\test\popen.py

I have tried a test program similar to Creating a Child Process with Redirected Input and Output and cannot find any combination of application-side updates or SSH/SSHd options and configuration changes.

If I kill the nested SSH process, the calling script or application print the expected output and finish gracefully. Looking at the debug output from the offending SSH process, the last line I see is:

debug2: channel 0: chan_shutdown_write (i3 o1 sock -1 wfd 5 efd 6 [write])

And I understand from a successful run that the following line SHOULD be:

debug2: channel 0: output drain -> closed

So it seems that my nested SSH call cannot properly close its output.

Expected output
>test test test
done

Actual output
Hangs until I manually kill the nested SSH process.

popen.txt

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the attached popen.txt reproduction and run it through ssh localhost python C:\Work\test\popen.py on the stated Windows client and server versions. Inspect the nested SSH debug output around chan_shutdown_write and compare it with the expected output drain -> closed line. Done means the nested process exits and produces <test test test> followed by done without manual termination.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, python
Domain
networking, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.