home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / sys / sun / misc / 3907 < prev    next >
Encoding:
Internet Message Format  |  1992-08-25  |  2.3 KB

  1. Xref: sparky comp.sys.sun.misc:3907 comp.unix.programmer:4440
  2. Newsgroups: comp.sys.sun.misc,comp.unix.programmer
  3. Path: sparky!uunet!ftpbox!mothost!merlin.dev.cdx.mot.com!fendahl.dev.cdx.mot.com!mcook
  4. From: mcook@fendahl.dev.cdx.mot.com (Michael Cook)
  5. Subject: Re: Yet another /dev/fd driver implementation
  6. Message-ID: <mcook.714759974@fendahl.dev.cdx.mot.com>
  7. Sender: news@merlin.dev.cdx.mot.com (USENET News System)
  8. Nntp-Posting-Host: fendahl.dev.cdx.mot.com
  9. Organization: Motorola Codex, Canton, Massachusetts
  10. References: <1992Aug23.171952.11050@colorado.edu>     <NICKEL.92Aug24174931@desaster.cs.tu-berlin.de> <QUANSTRO.92Aug24140601@lars.StOlaf.edu>
  11. Date: Tue, 25 Aug 1992 16:26:14 GMT
  12. Lines: 34
  13.  
  14. quanstro@lars.StOlaf.edu (goon) writes:
  15.  
  16. >In article <NICKEL.92Aug24174931@desaster.cs.tu-berlin.de> nickel@cs.tu-berlin.de (Juergen Nickelsen) writes:
  17. >   > This is an implementation of the /dev/fd driver. This driver provides
  18. >   > access to a process's file descriptors via the file system name space.
  19. >   > For example, when a process opens /dev/fd/9 the operation performed is
  20. >   > the equivalent of dup(9).
  21. >   > Standard input/output/error (i.e. descriptors 0,1,2) are also visible 
  22. >   > as /dev/{stdin,stdout,stderr}.
  23.  
  24. >   A similar driver has been posted some time ago.  Well, it really
  25. >   *looks* interesting, but what is the advantage for the programmer (or
  26. >   for someone else) to have the file descriptors as files?  
  27.  
  28. >Just a few examples:
  29. >o Consider your standard brain-dead program fu that will only read from
  30. >  files. With /dev/fd one can hallucinate fu into thinking that it is
  31. >  reading a file when you are feading it stdin. 
  32. >    bar | fu /dev/fd/0
  33. >o Suppose that you want to force a program to read from wierd file
  34. >  descriptors without hard-wiring the program. 
  35. >    make | groak_cryptic_errors_and_tell_emacs /dev/fd/2
  36. >o Suppose that you want a program to read directly from the output of
  37. >  several programs at once (i.e. non-linear pipes). It can read from
  38. >  /dev/fd/? on any { ? | ? is a valid (open for reading) file descriptor}.
  39.  
  40. The times I've wished I had /dev/stderr were when I was trying to get my AWK
  41. scripts to send their error messages to stderr.
  42.  
  43.     print "you goofed" > "/dev/stderr"
  44.  
  45. (BTW, GAWK'll simulate the /dev/std* and /dev/fd/* mechanisms for you.)
  46.  
  47. Michael.
  48.