From: swift@world.std.com (Peter Lu)
Subject: question/problem using fcntl to change file mode from text to binary
3 Jul 1997 15:33:39 -0700
Approved: cygnus.gnu-win32@cygnus.com
Distribution: cygnus
Message-ID: <33BC1462.7119.cygnus.gnu-win32@world.std.com>
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: gnu-win32@cygnus.com
Original-Sender: owner-gnu-win32@cygnus.com

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 swift@world.std.com.

Peter Lu
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".
