Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watnot!watmath!clyde!rutgers!uwvax!mcvoy From: mcvoy@uwvax.UUCP Newsgroups: comp.unix.questions,comp.unix.wizards,comp.lang.c Subject: Re: Filtering Everything Message-ID: <3446@rsch.WISC.EDU> Date: Sun, 12-Apr-87 17:00:17 EST Article-I.D.: rsch.3446 Posted: Sun Apr 12 17:00:17 1987 Date-Received: Tue, 14-Apr-87 00:08:57 EST References: <919@watmum.UUCP> <6447@bu-cs.BU.EDU> Reply-To: mcvoy@rsch.WISC.EDU (Larry McVoy) Distribution: comp Organization: U of Wisconsin CS Dept Lines: 36 Xref: utgpu comp.unix.questions:1690 comp.unix.wizards:1752 comp.lang.c:1579 (Someone) asks: >>I wish to write a program in C that I can somehow set up so all output >>to my terminal goes through it first, and all input from my terminal goes >>through it too. (Barry Shein) writes: >On 4.2/4.3 you want to do this via pty's. The script program is almost > >On SYSV I think you'll have difficulties doing what you say, especially >for terminal oriented programs (you mention vi.) Barry is quite right here (right, right, you're bloody well right [oops: digression]). To put it more succinctly, you cannot do this with some sort of pseudo tty support (I _know_ I've tried). The problem is that a lot of programs try to be (too?) smart about their environment and what they do is call isatty(3) which returns false if its' arg is not a file descriptor connected to a tty. [I learned this after writing a history filter for xlisp: it worked fine until I tried to call vi] Now, there is a way around this problem: It's a kludge, and depends on you using shared libs (like on the pc7300), but it's worth mentioning: Snag the source to isatty (or rewrite it) and have it return true for file descriptors that are pipes. Reinstall the function in the shared lib, reboot and away you go. Stuff like "vi foo | wc" will be mishandled, but who does that anyway? :-) Yeah, well, you asked, ok? BTW - SysV.3 *has* pttys - they're called sxt's (I think). Someone will jump on this if I'm wrong.... -- Larry McVoy mcvoy@rsch.wisc.edu or uwvax!mcvoy "It's a joke, son! I say, I say, a Joke!!" --Foghorn Leghorn