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