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

  1. Xref: sparky comp.unix.programmer:4463 comp.unix.questions:10424
  2. Path: sparky!uunet!munnari.oz.au!goanna!minyos.xx.rmit.oz.au!dtb
  3. From: dtb@otto.bf.rmit.oz.au (David Bath)
  4. Newsgroups: comp.unix.programmer,comp.unix.questions
  5. Subject: Re: Problem reading from pipe ("|") using read()
  6. Message-ID: <dtb.714875823@otto>
  7. Date: 27 Aug 92 00:37:03 GMT
  8. References: <1992Aug24.165613.17761@unocal.com>
  9. Sender: usenet@minyos.xx.rmit.oz.au (Njuiz noveles nova newes)
  10. Organization: RMIT Computer Centre, Melbourne Australia.
  11. Lines: 34
  12.  
  13. stsshol@st.unocal.COM (Herb Lam) writes:
  14.  
  15.  
  16. >First of all, my program reads input from standard in and writes to 
  17. >standard out.  I had used fread() and fwrite() to do I/O, but because I
  18. >needed to do some ioctls, it was suggested that I use read() and 
  19. >write() instead.  I did not have any problems until I changed all my
  20. >file pointers to file descriptors, fopen()/fclose() to open()/close(),
  21. >and fread()/fwrite() to read()/write().
  22.  
  23. >My problem is this.  When I run the program by itself, e.g.:
  24.  
  25. >    run < input > output
  26.  
  27. >Everything is fine.  However, if I get the input from the pipe:
  28.  
  29. >    "some program" < input | run > output
  30.  
  31. >The input to the "run" program gets messed up.  I don't get any system
  32.  
  33. >Any suggestions to solving this?
  34.  
  35. What about using popen()/pclose() then treat it like a file handle.
  36. I had a similar problem when debugging programs (written by someone else)
  37. that lost 1E5 records of 2E6 output a pipe.
  38.  
  39. General rule: If there is a section 3, use it, not the section 2
  40. Regards
  41.  
  42. ========================================================================
  43. David T. Bath
  44. email:     dtb@otto.bf.rmit.oz.au
  45. Work:     Global Technology Corporation, Carlton, Vic, OZ  (03) 3477511
  46. =======================================================================
  47.