scp and ssh 'cat' stalls at 64k bytes

Chris Roehrig croehrig@house.org
Sat Jun 24 08:45:33 GMT 2023



On 2023-06-24 00:12, Kevin Schnitzius wrote:
>   On Friday, June 23, 2023 at 10:00:02 PM EDT, Chris Roehrig via Cygwin <cygwin@cygwin.com> wrote:
>
>> Thanks.  There must be some issue with my setup.   Very odd that 'pv'
>> works, but 'cat' does not.  ldd shows they use identical libs.   I guess
>> I'll start with the pv and cat source.
> Try this first:
> /usr/bin/dd if=/dev/zero bs=1 count=65536 | /usr/bin/ssh localhost '/usr/bin/cat > /dev/null'
Good thought.   No change.   NB:  65536 always works fine. Anything 
greater (e.g. 65537)  does not work.
> Also, I assume you are running Cygwin's bash in a mintty term...
Yes, same results with both mintty  (Administrator or not) or slogged in 
remotely.

I found another one that works:  tee.

So these work fine (and /dev/null can be replaced by any file or 
omitted; doesn't matter):
dd if=/dev/urandom bs=1 count=65537 | ssh localhost 'wc'  # WORKS
dd if=/dev/urandom bs=1 count=65537 | ssh localhost 'tee /dev/null | cat 
 > /dev/null'    # WORKS
dd if=/dev/urandom bs=1 count=65537 | ssh localhost 'pv | cat > 
/dev/null'    # WORKS
dd if=/dev/urandom bs=1 count=65536 | ssh localhost 'cat > /dev/null'   
# WORKS


These don't:
dd if=/dev/urandom bs=1 count=65537 | ssh localhost 'cat | wc'   # STALLS
dd if=/dev/urandom bs=1 count=65537 | ssh localhost 'cat > /dev/null'   
# STALLS
dd if=/dev/urandom bs=1 count=65537 | ssh localhost 'awk {print} > 
/dev/null'   # STALLS
dd if=/dev/urandom bs=1 count=65537 | ssh localhost 'sed {} > /dev/null' 
   # STALLS


So pv, tee, and wc work,  but cat, sed, awk get hung up.

I also tried a simple python 3.9 implementation of 'cat' which works, 
and a gcc-compiled getchar/putchar one which stalls (which gives me 
something to work with).




More information about the Cygwin mailing list