[Cvsnt] SSH / Plink zombie processes on Win2k (+fix)
Boyd Meier
bmeier at acornsys.com
Tue May 7 19:49:24 BST 2002
I have been experiencing a problem with the cvsnt 1.11.3 client leaving ssh
or plink hanging as zombies on Win2k when the :ext: protocol is used. I
investigated further and found that the zombie is still hanging on open pipe
handles. I have a patch to protocol/common.c that fixes the problem on my
systems. However, be warned that I have not tested on anything other that
Win2K SP2.
Boyd
Here is the patch (against the current cvs):
--- cvsnt/cvsnt/protocols/common.c Tue May 7 11:10:16 2002
+++ cvsnt-1.11.1.3/protocols/common.c Mon May 6 15:44:04 2002
@@ -33,7 +33,7 @@
#define socket_errno errno
#endif
-
+enum PIPES { PIPE_READ = 0, PIPE_WRITE = 1 };
const struct server_interface *current_server;
static int tcp_fd;
@@ -195,18 +195,22 @@
PROCESS_INFORMATION pi;
BOOL status;
int fd1[2],fd2[2];
+ int fdcp1, fdcp2;
+
+ _pipe(fd1,0,_O_BINARY | _O_NOINHERIT);
+ _pipe(fd2,0,_O_BINARY | _O_NOINHERIT);
- _pipe(fd1,0,_O_BINARY);
- _pipe(fd2,0,_O_BINARY);
+ *in_fd=fd1[PIPE_READ];
+ *out_fd=fd2[PIPE_WRITE];
- *in_fd=fd1[0];
- *out_fd=fd2[1];
+ fdcp1 = _dup(fd1[PIPE_WRITE]);
+ fdcp2 = _dup(fd2[PIPE_READ]);
/* The STARTUPINFO structure can specify handles to pass to the
child as its standard input, output, and error. */
- si.hStdInput = (HANDLE) _get_osfhandle(fd2[0]);
- si.hStdOutput = (HANDLE) _get_osfhandle(fd1[1]);
- si.hStdError = (HANDLE) _get_osfhandle (2);
+ si.hStdInput = (HANDLE) _get_osfhandle(fdcp2);
+ si.hStdOutput = (HANDLE) _get_osfhandle(fdcp1);
+ si.hStdError = (HANDLE) _get_osfhandle (_fileno(stderr));
si.dwFlags = STARTF_USESTDHANDLES;
status = CreateProcess ((LPCTSTR) NULL,
@@ -240,6 +244,12 @@
}
return -1;
}
+
+ _close(fd1[PIPE_WRITE]);
+ _close(fd2[PIPE_READ]);
+ _close(fdcp1);
+ _close(fdcp2);
+
return 0;
}
#else
_______________________________________________
Cvsnt mailing list
Cvsnt at cvsnt.org
http://www.cvsnt.org/cgi-bin/mailman/listinfo/cvsnt
More information about the cvsnt
mailing list