home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / gnu / bash / bug / 657 < prev    next >
Encoding:
Text File  |  1992-11-19  |  2.9 KB  |  90 lines

  1. Newsgroups: gnu.bash.bug
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!hfrd.dsto.gov.au!dall
  3. From: dall@hfrd.dsto.gov.au (Ian Dall)
  4. Subject: Re: problem with bash + xon + sunos ...
  5. Message-ID: <1992Nov17.033736.8893@hfrd.dsto.gov.au>
  6. Sender: gnulists@ai.mit.edu
  7. Organization: Defence Science and Technology Organisation
  8. References: <9211051448.AA24758.SM@odin.INS.CWRU.Edu>
  9. Distribution: gnu
  10. Date: Tue, 17 Nov 1992 03:37:36 GMT
  11. Approved: bug-bash@prep.ai.mit.edu
  12. Lines: 76
  13.  
  14.  
  15. In article <9211051448.AA24758.SM@odin.INS.CWRU.Edu>, chet@odin.ins.cwru.edu (Chet Ramey) writes:
  16. > This is a bug alright, but it's a bug with rshd that's not fixed until
  17. > 4.3-reno.
  18. > rshd sets up a pipe (int pv[2]; if you have the source to the tahoe rshd)
  19. > to the process it executes and uses it to manage error and control output
  20. > from over the net.  In the child process, it does a dup2(pv[1], 2), but
  21. > never calls close(pv[1]).  Adding that code to the 4.3-tahoe rshd makes it
  22. > (and the Xemacs script) work right.
  23. > I don't know how to solve this cleanly in bash.  Doing a blanket close of
  24. > all open file descriptors > 2, < 20 is a no-no, especially when we're not
  25. > interactive.  csh `works' because it does the blanket close on startup, but
  26. > csh can get away with doing that because it doesn't let you manipulate
  27. > arbitrary file descriptors.
  28.  
  29. At least on this machine the problem appears to be more that just one
  30. with rsh. For years I have been using the exec n>&- trick to fix the
  31. rsh problem. (Where n is the problem file desciptor). With the
  32. current version of bash, that doesn't seem to work.
  33.  
  34. I have a program called "nfiledes" which figures out what file desciptors
  35. are open:
  36.  
  37.     cronus:-dall $ bash
  38.     cronus:-dall $ exec nfiledes
  39.     File descriptor 5 open.
  40.     File descriptor 2 open.
  41.     File descriptor 1 open.
  42.     File descriptor 0 open.
  43.     4 file descriptors open across execs.
  44.     cronus:-dall $ bash
  45.     cronus:-dall $ exec nfiledes 5>&-
  46.     File descriptor 10 open.
  47.     File descriptor 2 open.
  48.     File descriptor 1 open.
  49.     File descriptor 0 open.
  50.     4 file descriptors open across execs.
  51.  
  52.  
  53. Note that as soon as I try and close file desciptor 5, something (and
  54. I can't think how it could be anything except bash) opens a new file
  55. descriptor (10). (And if I close 10 it opens 11).
  56.  
  57.  
  58. This is
  59.     BASH_VERSION=1.12.1
  60.  
  61. on a DECstation 5000 (mips R3000) running Ultrix 4.2.
  62.  
  63. Here is the source for nfiledes.c
  64.  
  65. /* Count the number of file descriptors currently open */
  66. #include <stdio.h>
  67. #include <fcntl.h>
  68. main ()
  69. {
  70.   int ret, i, n = 0;
  71.   for ( i = _NFILE; i--;)
  72.     if ( (ret = fcntl(i, F_GETFD, 0)) != -1)
  73.       {
  74.     printf("File descriptor %d open.\n", i);
  75.     n += (!ret) & 1;
  76.       }
  77.   printf("%d file descriptors open across execs.\n", n);
  78. }
  79.  
  80.  
  81. Ian
  82. -- 
  83. Ian Dall          I'm not into isms, but hedonism is the most
  84.                   harmless I can think of. -- Phillip Adams
  85.  
  86. internet: dall@hfrd.dsto.gov.au
  87.  
  88.