🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.bash.bug
Article #942

Re: problem with bash + xon + sunos ...

#942
From: Chet Ramey
Date: Thu, 05 Nov 1992 04:48
57 lines
3214 bytes
> I have `bash' as my standard login shell under sunos 4.1.1 and I am
> trying to use the X11 R5 script `xon' that allow to create an xterm
> on a remote machine using your local display.  Has anybody noticed
> that on the sun the xon script keep the connection open until the 
> remote xterm dies.
> 
> The xon script does something like this:
> 
>   rsh remotehost "sh -c 'DISPLAY=currentdisplay:0.0 xterm -ls >/dev/null \
>   2>&1 &'"
> 
> This should run the remote xterm in the background at the remote host.
> 
> If your login shell is bash then the rsh command hangs until the remote
> xterm dies.  If your login shell is csh or your remote host is not 
> running sunos (e.g. rs6000 running bash) then the xon command terminate
> immediatly without waiting for the remote xterm to die.

It's a bug in rsh that Sun has not yet fixed.  Here's a message I sent to
the IBM guy who had the same problem (which is why it's fixed in AIX):

Date: Sat, 27 Apr 91 19:31:16 -0400
From: Chet Ramey <chet@odin.INS.CWRU.Edu>
To: bfox@ai.mit.edu
Subject: Re: [pedz@aixwiz.austin.ibm.com: fd 9 left open bug]
Cc: chet@odin.INS.CWRU.Edu, pedz@aixwiz.austin.ibm.com

> Below is something I call Xemacs which goes across the net, sets up the
> display variable and then kicks off emacs in such a way that rshd
> terminates.  The trick is that the shell must die and all file
> descriptors going back to rshd must be closed.  The same basic script
> works with csh but I had to add in the "9>&-" part at the end to make
> it work with bash.   This is because somehow, file descriptor 9 is left
> open and I guess it must be a dup of stdin, stdout, or stderr.

This is a bug alright, but it's a bug with rshd that's not fixed until
4.3-reno.

rshd sets up a pipe (int pv[2]; if you have the source to the tahoe rshd)
to the process it executes and uses it to manage error and control output
from over the net.  In the child process, it does a dup2(pv[1], 2), but
never calls close(pv[1]).  Adding that code to the 4.3-tahoe rshd makes it
(and the Xemacs script) work right.

I don't know how to solve this cleanly in bash.  Doing a blanket close of
all open file descriptors > 2, < 20 is a no-no, especially when we're not
interactive.  csh `works' because it does the blanket close on startup, but
csh can get away with doing that because it doesn't let you manipulate
arbitrary file descriptors.

Chet

--
``The use of history as therapy means the corruption of history as history.''
	-- Arthur Schlesinger

Chet Ramey, Case Western Reserve University	Internet: chet@po.CWRU.Edu
Technical Details
Message-ID: <9211051448.AA24758.SM@odin.INS.CWRU.Edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!charon.amdahl.com!pacbell.com!decwrl!sun-barr!ames!saimiri.primate.wisc.edu!sdd.hp.com!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!odin.ins.cwru.edu!chet
References: chet@odin.ins.cwru.edu (Chet Ramey)

Show Full Headers
Complete Article Headers
Newsgroups: gnu.bash.bug
Path: arc1-ca.pugleaf.net!sparky!uunet!charon.amdahl.com!pacbell.com!decwrl!sun-barr!ames!saimiri.primate.wisc.edu!sdd.hp.com!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!odin.ins.cwru.edu!chet
From: chet@odin.ins.cwru.edu (Chet Ramey)
Subject: Re: problem with bash + xon + sunos ...
Message-ID: <9211051448.AA24758.SM@odin.INS.CWRU.Edu>
Sender: gnulists@ai.mit.edu
Reply-To: chet@po.cwru.edu
Organization: GNUs Not Usenet
References: chet@odin.ins.cwru.edu (Chet Ramey)
Distribution: gnu
Date: Thu, 5 Nov 1992 04:48:35 GMT
Approved: bug-bash@prep.ai.mit.edu
Lines: 58