SUMMARY: Rsh Feature is causing me a Headache!!!

From: Guy Freeman (Guy.Freeman@ing-barings.com)
Date: Thu Sep 19 1996 - 06:42:48 CDT


     Thanks for all your quick replies to this one.
     
     Because the child process (in this case sleep) keeps open STDIN,
     STDOUT and STDERR, rshd does not terminate just in case you want to
     read the output or write to the input of this process. Fair enough I
     suppose.
     
     Two common solutions that I could *NOT* use were to redirect
     STDIN/OUT/ERR to /dev/null on the remote host, eg.
     
        rsh -n remote_host /tmp/test.csh '</dev/null >&/dev/null'
     
     Or do it inside the startup script, eg.
     
        #!/bin/csh -f
        ...
        sleep 60 & </dev/null >&/dev/null
        ...
     
     I could not use these solutions because in the first case, I need the
     output messages from the startup script, and in the second case, there are
     lots of startup scripts on many servers and I don't want to modify them
     all.
     
     The solution I will use was to redirect STDIN to /dev/null and STDOUT/ERR
     to a file, and when the rsh command ends, run another one to cat the file,
     eg.
     
        set tmpfile="rshout.$$"
        rsh -n remote_host /tmp/test.csh "</dev/null >&$tmpfile"
        rsh -n remote_host "cat $tmpfile ; rm -f $tmpfile"
     
     Btw, somebody did point out, very correctly, that "proper" daemons should
     close off STDIN/OUT/ERR when they start.....
     
     Thanks *very* much to *everyone* who responded,
     
     Guy
     
     
     My Original Mail:
     ---------------------------------------------------------------------
     Hi there,
     
     I need to use rsh to run scripts on remote machines which start off
     application daemons. These scripts write some useful messages to the
     screen, start the daemon off in the background, then end. However,
     I've discovered a "feature" of rsh which is causing me a serious
     headache which is:-
     
     When you use rsh to start processes off on remote machines, the rsh
     command does not end until the process ***and any child processes***
     have ended, ie. if you fork off a daemon in the background, the rsh
     will not end until the daemon ends, ie. never. To simulate this
     problem, create the following script on a remote machine:
     
        #!/bin/csh -f
        echo "Starting sleep in the background..."
        sleep 60 &
        echo "Done"
     
     And call it /tmp/test.csh. Then run it using rsh:
     
        rsh remote_host /tmp/test.csh
     
     You'll get the "Done" message but the rsh command will hang for 60
     seconds before ending.
     
     I *MUST* (and intend to) work out a solution to this problem. Can
     anybody help?????
     
     Thank you in advance,
     
     Guy



This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:11:10 CDT