home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: gnu.bash.bug
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!hfrd.dsto.gov.au!dall
- From: dall@hfrd.dsto.gov.au (Ian Dall)
- Subject: Re: problem with bash + xon + sunos ...
- Message-ID: <1992Nov17.033736.8893@hfrd.dsto.gov.au>
- Sender: gnulists@ai.mit.edu
- Organization: Defence Science and Technology Organisation
- References: <9211051448.AA24758.SM@odin.INS.CWRU.Edu>
- Distribution: gnu
- Date: Tue, 17 Nov 1992 03:37:36 GMT
- Approved: bug-bash@prep.ai.mit.edu
- Lines: 76
-
-
- In article <9211051448.AA24758.SM@odin.INS.CWRU.Edu>, chet@odin.ins.cwru.edu (Chet Ramey) writes:
- > 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.
-
- At least on this machine the problem appears to be more that just one
- with rsh. For years I have been using the exec n>&- trick to fix the
- rsh problem. (Where n is the problem file desciptor). With the
- current version of bash, that doesn't seem to work.
-
- I have a program called "nfiledes" which figures out what file desciptors
- are open:
-
- cronus:-dall $ bash
- cronus:-dall $ exec nfiledes
- File descriptor 5 open.
- File descriptor 2 open.
- File descriptor 1 open.
- File descriptor 0 open.
- 4 file descriptors open across execs.
- cronus:-dall $ bash
- cronus:-dall $ exec nfiledes 5>&-
- File descriptor 10 open.
- File descriptor 2 open.
- File descriptor 1 open.
- File descriptor 0 open.
- 4 file descriptors open across execs.
-
-
- Note that as soon as I try and close file desciptor 5, something (and
- I can't think how it could be anything except bash) opens a new file
- descriptor (10). (And if I close 10 it opens 11).
-
-
- This is
- BASH_VERSION=1.12.1
-
- on a DECstation 5000 (mips R3000) running Ultrix 4.2.
-
- Here is the source for nfiledes.c
-
- /* Count the number of file descriptors currently open */
- #include <stdio.h>
- #include <fcntl.h>
- main ()
- {
- int ret, i, n = 0;
- for ( i = _NFILE; i--;)
- if ( (ret = fcntl(i, F_GETFD, 0)) != -1)
- {
- printf("File descriptor %d open.\n", i);
- n += (!ret) & 1;
- }
- printf("%d file descriptors open across execs.\n", n);
- }
-
-
- Ian
- --
- Ian Dall I'm not into isms, but hedonism is the most
- harmless I can think of. -- Phillip Adams
-
- internet: dall@hfrd.dsto.gov.au
-
-