Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!bloom-beacon!mit-eddie!bbn!spdcc!ima!haddock!karl From: karl@haddock.ima.isc.com (Karl Heuer) Newsgroups: comp.lang.c Subject: Re: Getchar w/wout echo Message-ID: <6610@haddock.ima.isc.com> Date: 26 Aug 88 15:36:03 GMT References: <6589@haddock.ima.isc.com> <3761@bsu-cs.UUCP> Reply-To: karl@haddock.ima.isc.com (Karl Heuer) Organization: Interactive Systems, Boston Lines: 36 In article <3761@bsu-cs.UUCP> dhesi@bsu-cs.UUCP (Rahul Dhesi) writes: >In article <6589@haddock.ima.isc.com> karl@haddock (Karl Heuer) writes: >>The system is always in one of two states, cooked or raw > >It would be nice if we applied the concept of raw-versus-cooked to the >current input request rather than to the terminal. This way there is >no danger of programming carelessness (or having to kill a runaway >process) leaving the terminal in a funny state. This happens more >often than I like on UNIX systems. While this behavior may be more desirable for some applications, insisting on it would require too much overhead on UNIX. My proposal was designed so that rawenable(); while ((c = getrawchar()) != QUIT_CMD) do_command(c); rawdisable(); could be implemented with just one system call (instead of three) for each iteration of the loop. To defend against the "funny state" problem, you can set up traps: signal(SIGINT, rawdisable); atexit(rawdisable); (My "tio" package has an option to automatically do this when you call the equivalent of rawenable().) Alternately, you could get the exact behavior you described by wrapping another layer around the primitives: int getch(void) { int c; rawenable(); c = getrawchar(); rawdisable(); return c; } If what you're really saying is that UNIX should be changed, then I agree (a "/dev/rtty" would be within the Spirit). But that's not a C issue. Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint