Why does scp leave ssh running? -- select() never returns

Patrick Doyle wpd@delcomsys.com
Mon Jan 8 06:24:00 GMT 2001

Ehud Karni wrote:
> On Sat, 06 Jan 2001 22:22:24 -0500, Patrick Doyle <wpd@delcomsys.com> wrote:
> >
> > I have been working on a hack workaround for this problem.  (Short
> > summary -- select() fails to detect when all of the writers of a pipe
> > have closed the pipe because PeekNamedPipe() on W9x boxen fails to
> > report when all of the writers of a pipe have closed the pipe.  I am
> > told that this all works correctly on NT/2K boxen).
> My work around for Win95/98 is a bash script, executed directly from
> the windows command (I associated sh with /bin/bash):
Thanks for the excellent script.  It looks like it solves the specific
problem that I was complaining about (namely that scp leaves an ssh
running), but unfortunately it doesn't solve other related problems that
share the same root cause.  For example, using SSH with CVS appears to
hang at the end of the CVS operation.  (CVS is waiting for SSH to
complete.  SSH is waiting to detect an EOF on its input pipe).  I am
hoping to solve this problem in the cygwil DLL, so that it is solved
once, rather than for each application that encounters it.

> > Basically, I have modified 'pipe()' to create two windows pipes (on W9x
> > boxen).  The first pipe is the same one that has always been created.
> > [ snip ]
> Well, it seems a very complicated work around for the W9x bug. I would
> have taken a much simpler and direct approach like this:
>    1) Save the child (ssh) process id in a global variable,
>            (i.e. child=fork() ;)
>    2) Just before exiting, send kill signal to the child with no
>      checks,  (i.e. kill(child, SIGTERM) ;)
> This might look like brute force, but it works. It has the advantage
> that it works with ssh unmodified and with any other program that may
> be given as argument to scp.
I think that you are saying that your approach would have been to modify
scp (and later cvs) to work around this problem.  Again, I would rather
fix it in the library, and not have to modify each application that runs
into this.  I admit, my solution is complicated, it is a hack, in the
end I may never be able to make it work right, etc..., but, so far, it
is the only viable approach that I have been able to envision.  Every
other approach I have thought of runs into the problem that it depends
on capabilities that are in NT/2K, but not W9x.  Sigh...  I really
appreciate Christoper's statement that he hates Window 9x programming.


Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple

More information about the Cygwin mailing list