Subject: Re: OpenSSH and WinCVS in Windows 9x
From: egor duda <[email-masked]>
To: Laurent Pinchart <[email-masked]>
Cc: [email-masked]
Date: Thu, 8 Aug 2002 16:18:59 +0400

Hi!

Thursday, 08 August, 2002 Laurent Pinchart [email-masked] wrote:

LP> WinCVS creates the ssh process by calling CreateProcess, which has stdin and
LP> stdout redirected to pipes. The pipes are then converted to C file 
LP> descriptors, which in turn are converted to FILE pointers. Closing those 
LP> FILEs doesn't make ssh terminate.

LP> I tried to modify the WinCVS code, and closed all the pipe handles right after 
LP> creating the child process (ssh). This doesn't make the child process 
LP> terminate.

LP> I suppose that it is then a bug in OpenSSH/Cygwin. I'll try to investigate in 
LP> the OpenSSH sources. My guess is that OpenSSH calls select() on the standard 
LP> input, and fails to detect that the pipe has been closed. Once again, this 
LP> only occurs in Win98, not in Win2k.

Cygwin uses the following code to periodically probe pipe status:

(file select.cc)
static int
peek_pipe (select_record *s, bool from_select)
...
else if (!PeekNamedPipe (h, NULL, 0, NULL, (DWORD *) &n, NULL))
   {
     select_printf ("%s, PeekNamedPipe failed, %E", fh->get_name ());
     n = -1;
   }
...

Peeking into pipe for zero bytes is quite unusual, so win98 may return
something wrong here. You can probably attach with a debugger or strace
to running ssh instance and look what's going on. Maybe we'd have to
probe for at least 1 byte here. Or maybe use some totally different
approach to detect if peer's end of pipe is closed.

I vaguely remember some problems with PeekNamedPipe from times when i
patched tty stuff, but they were somewhat different.

LP> I'm not very familiar with pipes on windows, so I'd appreciate help on this 
LP> subject.

Egor.            mailto:[email-masked] ICQ 5165414 FidoNet 2:5020/496.19

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/