[PATCH]: scp could hang in Cygwin

Corinna Vinschen vinschen at redhat.com
Tue Apr 3 05:58:29 EST 2001


Hi,

attached is a patch which solves the following problem:

Sometimes scp could hang in Cygwin when used as remote end using
the -t option. This is due to a binmode/textmode problem which
could be raised by the login shell which is used by the user and
it's setting of textmode on stdin. The patch solves that problem
by explicitly setting binmode on stdin.

Besides solving the hanging problem, the patch results in a way
faster copy process.

Corinna

Index: scp.c
===================================================================
RCS file: /cvs/openssh_cvs/scp.c,v
retrieving revision 1.66
diff -u -p -r1.66 scp.c
--- scp.c	2001/03/29 00:43:54	1.66
+++ scp.c	2001/04/02 19:47:14
@@ -291,6 +291,9 @@ main(argc, argv)
 		case 't':	/* "to" */
 			iamremote = 1;
 			tflag = 1;
+#ifdef HAVE_CYGWIN
+			setmode (0, O_BINARY);
+#endif
 			break;
 		default:
 			usage();
Index: openbsd-compat/bsd-cygwin_util.c
===================================================================
RCS file: /cvs/openssh_cvs/openbsd-compat/bsd-cygwin_util.c,v
retrieving revision 1.3
diff -u -p -r1.3 bsd-cygwin_util.c
--- openbsd-compat/bsd-cygwin_util.c	2001/02/18 01:30:56	1.3
+++ openbsd-compat/bsd-cygwin_util.c	2001/04/02 19:47:14
@@ -20,7 +20,6 @@ RCSID("$Id: bsd-cygwin_util.c,v 1.3 2001
 #ifdef HAVE_CYGWIN
 
 #include <fcntl.h>
-#include <io.h>
 #include <stdlib.h>
 #include <sys/vfs.h>
 #include <windows.h>
Index: openbsd-compat/bsd-cygwin_util.h
===================================================================
RCS file: /cvs/openssh_cvs/openbsd-compat/bsd-cygwin_util.h,v
retrieving revision 1.3
diff -u -p -r1.3 bsd-cygwin_util.h
--- openbsd-compat/bsd-cygwin_util.h	2001/02/18 01:30:56	1.3
+++ openbsd-compat/bsd-cygwin_util.h	2001/04/02 19:47:14
@@ -20,6 +20,8 @@
 
 #ifdef HAVE_CYGWIN
 
+#include <io.h>
+
 int binary_open(const char *filename, int flags, ...);
 int binary_pipe(int fd[2]);
 int check_nt_auth(int pwd_authenticated, uid_t uid);

-- 
Corinna Vinschen
Cygwin Developer
Red Hat, Inc.
mailto:vinschen at redhat.com



More information about the openssh-unix-dev mailing list