Subject: question/problem using fcntl to change file mode from text to binary
From: [email-masked] (Peter Lu)

3 Jul 1997 15:33:39 -0700
Approved: [email-masked]
Distribution: cygnus
Message-ID: <[email-masked]>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Mailer: Mozilla 3.0 (X11; I; HP-UX A.09.07 9000/777)
Original-To: [email-masked]
Original-Sender: [email-masked]

Hi,

	I am having problems using fcntl() to change a file which was
opened in text mode that I'd like to use in binary mode.  In particular,
I'd like to change my standard input and output (fd=0 and fd=1) to
binary so that I can create a filter program.  Right now, I do:

#include <fcntl.h>

.....

flag = fcntl(0, F_GETFL);
flag |= _FBINARY;
fcntl(0, F_SETFL, flag);
.....

but this doesn't seem to work.  As a matter of fact, flag seems to
retrieve some nonsensible value (perhaps the fd itself).

If this doesn't work, how much work-around do I need to do?  I read that
an open() with O_BINARY would do the trick for new files.  Perhaps I'll
give fdopen a try.  Does fcntl() work right now?

Thanks for any help.  Please email [email-masked].

Peter Lu
-
For help on using this list (especially unsubscribing), send a message to
"[email-masked]" with one line of text: "help".