home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.unix.programmer:4452 comp.unix.questions:10397
- Newsgroups: comp.unix.programmer,comp.unix.questions
- Path: sparky!uunet!paladin.american.edu!darwin.sura.net!jvnc.net!yale.edu!ira.uka.de!Germany.EU.net!murignis!ap542!D012S436!frank
- From: frank@D012S436.sniap.mchp.sni.de ()
- Subject: Re: Problem reading from pipe ("|") using read()
- Message-ID: <1992Aug26.143218.8576@sniap.mchp.sni.de>
- Sender: news@sniap.mchp.sni.de (News Admin)
- Organization: Siemens-Nixdorf AG
- References: <1992Aug24.165613.17761@unocal.com>
- Date: Wed, 26 Aug 92 14:32:18 GMT
- Lines: 49
-
- 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
-
-
- What does "messed up" mean? You need to supply
- more info if anyone is going to be able to help you
- with this.
-
- What does your read call look like?
-
- Are you using any other system calls (e.g fork()?)
-
- : errors. I believe the problem is with read(), but I don't know how or
- : why it is doing this. Someone suggested that it may be due to some
- : buffering problem in read(). Can anyone elaborate on this? Since the
- : default for the program is standard in and standard out, I do not need
- : to use open() to open standard in and standard out, right? I've checked
- : the file descriptors when I run the program and they are correct: 0 for
- : input and 1 for output.
- :
- : Any suggestions to solving this?
- :
-
- I doubt it, unless you give us some more info...
-
- : Thanks,
- :
- : Herb
- --
- Frank O'Dwyer Disclaimer:
- Siemens-Nixdorf AG I will deny everything
- Tel. : +49 (89) 636-40639 Fax. : +49 (89) 636-45860
- e-mail: Frank.ODwyer@sniap.mchp.sni.de
-