home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / unix / programm / 4452 < prev    next >
Encoding:
Internet Message Format  |  1992-08-26  |  2.3 KB

  1. Xref: sparky comp.unix.programmer:4452 comp.unix.questions:10397
  2. Newsgroups: comp.unix.programmer,comp.unix.questions
  3. Path: sparky!uunet!paladin.american.edu!darwin.sura.net!jvnc.net!yale.edu!ira.uka.de!Germany.EU.net!murignis!ap542!D012S436!frank
  4. From: frank@D012S436.sniap.mchp.sni.de ()
  5. Subject: Re: Problem reading from pipe ("|") using read()
  6. Message-ID: <1992Aug26.143218.8576@sniap.mchp.sni.de>
  7. Sender: news@sniap.mchp.sni.de (News Admin)
  8. Organization: Siemens-Nixdorf AG
  9. References: <1992Aug24.165613.17761@unocal.com>
  10. Date: Wed, 26 Aug 92 14:32:18 GMT
  11. Lines: 49
  12.  
  13. stsshol@st.unocal.COM (Herb Lam) writes:
  14. : First of all, my program reads input from standard in and writes to 
  15. : standard out.  I had used fread() and fwrite() to do I/O, but because I
  16. : needed to do some ioctls, it was suggested that I use read() and 
  17. : write() instead.  I did not have any problems until I changed all my
  18. : file pointers to file descriptors, fopen()/fclose() to open()/close(),
  19. : and fread()/fwrite() to read()/write().
  20. : My problem is this.  When I run the program by itself, e.g.:
  21. :     run < input > output
  22. : Everything is fine.  However, if I get the input from the pipe:
  23. :     "some program" < input | run > output
  24. : The input to the "run" program gets messed up.  I don't get any system
  25.  
  26.  
  27. What does "messed up" mean?  You need to supply
  28. more info if anyone is going to be able to help you
  29. with this.  
  30.  
  31. What does your read call look like?
  32.  
  33. Are you using any other system calls (e.g fork()?) 
  34.  
  35. : errors.  I believe the problem is with read(), but I don't know how or
  36. : why it is doing this.  Someone suggested that it may be due to some 
  37. : buffering problem in read().  Can anyone elaborate on this?  Since the 
  38. : default for the program is standard in and standard out, I do not need 
  39. : to use open() to open standard in and standard out, right?  I've checked
  40. : the file descriptors when I run the program and they are correct:  0 for
  41. : input and 1 for output.
  42. : Any suggestions to solving this?
  43.  
  44. I doubt it, unless you give us some more info...
  45.  
  46. : Thanks,
  47. :     Herb
  48. --
  49. Frank O'Dwyer                           Disclaimer: 
  50. Siemens-Nixdorf AG                             I will deny everything
  51. Tel.  : +49 (89) 636-40639                      Fax.  : +49 (89) 636-45860
  52. e-mail: Frank.ODwyer@sniap.mchp.sni.de
  53.