Date: Mon, 27 Sep 1999 09:53:16 +0200 (IST) From: Eli Zaretskii X-Sender: eliz AT is To: Bonifati cc: djgpp AT delorie DOT com Subject: Re: open console into binary mode ? In-Reply-To: <7slfup$m1f$1@fe2.cs.interbusiness.it> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Reply-To: djgpp AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk On Sun, 26 Sep 1999, Bonifati wrote: > i have to write some filter programs which must work for binary files, not > only for text ones. > > i tried to open console into binary mode, but my program crashes when the > input isn't redirect from a file. It doesn't crash, see below. But I don't understand why did you need to switch the console device into binary mode when what you need is to process binary files. Specifically, what does processing binary files have to do with the text/binary mode of the console? > C:\> test > the program hangs! > nothing appears if i press some keys and CTRL-Break doesn't work! This is all explained in the library docs, under the `setmode' function. Switching the console into binary mode has the side effect of switching the CON device into the so-called raw (as opposed to cooked) mode. In raw mode, characters are read one by one with no echo, and Ctrl-BREAK and Ctrl-C are by default disabled. So your program actually is alive and cicking, it just appears to hang because you don't see any characters being echoed, and because you cannot terminate the program by any means (Ctrl-Z is also ignored in raw mode, so you cannot signal EOF). Please be sure to read the docs for `setmode' and `signal' for more details. As I said above, I don't understand why did you need to switch the console to binary mode in the first place. My guess is that this is not needed for your application. Please explain what you are trying to accomplish and why do you think the default text mode of the console is not good enough for that.