Subject: Re: Why does scp leave ssh running? -- select() never returns
From: "Ehud Karni" <[email-masked]>
To: [email-masked]
Cc: [email-masked]
Date: Mon, 8 Jan 2001 13:21:10 +0200

On Sat, 06 Jan 2001 22:22:24 -0500, Patrick Doyle <[email-masked]> 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):

#! /bin/sh -ex
# --------------------------------------------------

set +e
scp -p -v -r -C "$1" ehud@ekc-1:$2

set +x
GRP=`ps | grep "[/]PS"`                    # find this PS line      
GRP=`echo $GRP | cut "-d " -f3`            # compress spaces        
PID=`ps | grep $GRP | grep "[/]bin[/]SSH"` # My ssh line            
PID=`echo $PID | cut "-d " -f1`            # compress spaces        
                                                                    
ps                                         # show running processes 
set -x                                                              
                                                                    
if [ "$PID" != "" ] ; then                 # is there "My SSH"      
    kill $PID                              # yes kill it            
else                                                                
    : " Error in copy to linux "           # no, error message      
fi                                                                  
sleep 30                                   # keep console open      
                                           
############################## scpt.sh ##############################

> 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.

Ehud.

-- 
 @@@@@@ @@@ @@@@@@ @    @   Ehud Karni  Simon & Wiesel  Insurance agency
     @    @      @  @@  @   Tel: +972-3-6212-757    Fax: +972-3-6292-544
     @    @ @    @ @  @@    (USA)  Fax  and  voice  mail:  1-815-5509341
     @    @ @    @ @    @        Better     Safe     Than     Sorry
 http://www.simonwiesel.co.il    mailto:[email-masked]

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