Warum hängt Readfile auf Stdin mit mindestens 64 kib unter SSH?C++

Programme in C++. Entwicklerforum
Anonymous
 Warum hängt Readfile auf Stdin mit mindestens 64 kib unter SSH?

Post by Anonymous »

Frage < /h2>
Ich versuche die folgenden Symptome zu verstehen: < /p>

Ich habe ein C ++ - Programm, das Windows
verwendet

Code: Select all

ReadFile< /code>
zum Lesen (und Abwerfen) des gesamten Stdin. Über Cygwin ssh localhost 
. Strg+C tötet DD < /code> und ssh < /code>, verlässt das Programm jedoch
, daher muss ich es mit Process Explorer oder Task -Manager töten. funktioniert. Also kann ich robust um
umgehen, was auch immer das Problem ist.

Code: Select all

// readfile.cc
// Just read (and discard) all of stdin using ReadFile.

#include                      // std::atoi
#include                     // std::{cout, endl}
#include                       // std::vector

#include                    // ReadFile, etc.

#define DIAG(stuff) std::cout 
~/tmp$ dd if=/dev/zero bs=200k count=1 status=none | ssh localhost tmp/readfile 65536
[hang]
Fortsetzung, wenn ich jetzt ReadFile im Prozess-Explorer töte, sehe ich:

Code: Select all

maxSize: 65536
calling ReadFile with size 65536
ReadFile: bytesRead=65536
calling ReadFile with size 65536
Exit 1           [This is printed by my shell.]
< /code>
Für Klarheit lautet der Datenfluss zwischen den Programmen: < /p>
dd (Cygwin) -> ssh (Cygwin) -> sshd (Cygwin) -> readfile.exe (Native Windows)
< /code>
Basierend auf der obigen Ausgabe scheint es, dass der Hang im Aufruf
Second Readfile < /code> auftritt, obwohl diese Ausgabe nur  nach < /em> i Kill
den Prozess erscheint.   Eine Möglichkeit besteht darin, dass SSH < /code> es puffert, aber wenn ja,
sehe ich keine
Option zum Deaktivieren
-That.
Ausführen zeigt, dass es mit einer etwas kleineren Größe in Ordnung ist: < /p>
">"> ">"> ">"> ">"> ">"> ">"> ">"> ">"> ">"> ">"> ">"> ">"> ">"> ">"> ">"> ">"> ">"> ">"> ">"> ">"> ">">~/tmp$ dd if=/dev/zero bs=200k count=1 status=none | ssh localhost tmp/readfile 65535
maxSize: 65535
calling ReadFile with size 65535
ReadFile: bytesRead=65535
calling ReadFile with size 65535
ReadFile: bytesRead=1
calling ReadFile with size 65535
ReadFile: bytesRead=65535
calling ReadFile with size 65535
ReadFile: bytesRead=1
calling ReadFile with size 65535
ReadFile: bytesRead=65535
calling ReadFile with size 65535
ReadFile: bytesRead=1
calling ReadFile with size 65535
ReadFile: bytesRead=8192
calling ReadFile with size 65535
broken pipe
readfile done
< /code>
Ausführen und zeigen, dass es ohne SSH in Ordnung ist: < /p>
~/tmp$ dd if=/dev/zero bs=200k count=1 status=none | ./readfile 65536
maxSize: 65536
calling ReadFile with size 65536
ReadFile: bytesRead=65536
calling ReadFile with size 65536
ReadFile: bytesRead=65536
calling ReadFile with size 65536
ReadFile: bytesRead=65536
calling ReadFile with size 65536
ReadFile: bytesRead=8192
calling ReadFile with size 65536
broken pipe
readfile done
Es funktioniert bei der Verwendung von DD an beiden Enden:

Code: Select all

$ dd if=/dev/zero bs=200k count=1 status=none | ssh localhost dd of=/dev/null bs=200k count=1 status=none
< /code>
 Umgebung < /h2>
Ich verwende Winlibs mingw: < /p>
$ g++ --version
g++.exe (MinGW-W64 x86_64-ucrt-mcf-seh, built by Brecht Sanders) 13.2.0
< /code>
Ich verwende Cygwin SSH: < /p>
$ ssh -V
OpenSSH_9.3p1, OpenSSL 1.1.1u  30 May 2023
$ bash --version
GNU bash, version 5.2.15(3)-release (x86_64-pc-cygwin)
$ uname -a
CYGWIN_NT-10.0-19045 coral-win10 3.4.7-1.x86_64 2023-06-16 14:04 UTC x86_64 Cygwin
Ich führe diese Programme normalerweise innerhalb eines Cygwin Xterm aus, aber die gleichen Symptome treten bei Verwendung von Mintty .>

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post