Path: utzoo!utgpu!watserv1!ria!uwovax!7103_2622 From: 7103_2622@uwovax.uwo.ca (Eric Smith) Newsgroups: comp.sys.atari.st.tech Subject: Re: MicroRTX patch and isatty() fix Message-ID: <6680.26c75e67@uwovax.uwo.ca> Date: 14 Aug 90 06:13:59 GMT References: <4352@bdt.UUCP> Lines: 36 In article <4352@bdt.UUCP>, david@bdt.UUCP (David Beckemeyer) writes: > Recently it was brought to my attention that the isatty() code in > the dLibs and GCC libraries doesn't work with programs run under > Micro RTX because RTX handles the Fseek() GEMDOS call a little > differently. > > Basically the isatty() code tries to do Fseek() and if it gets a > zero back, it assumes the thing isn't seekable and therefore must > be a tty. In RTX, Fseek() returns -37 (invalid handle) on non > seekable files. This confuses the isatty() code. Below is a > program (uuencoded) that will patch RTX V1.13 so that RTX Fseek() > returns zero like normal GEMDOS Fseek(). > > This doesn't fix the whole problem, because the isatty() still > doesn't understand what to do with pipes. Basically all the isatty() > routines that I've seen assume that if the handle is seekable, then > it's a file, otherwise it's a tty. Well in RTX, a handle could be > a pipe, in which case it's not seekable, but it's not a tty either > (it should be treated like a file). The GCC isatty() code has a default return value of 0, i.e. if an error occurs, it's assumed that the handle is not a tty. Thus, if pipes give an error (e.g. -37, as they used to in RTX) and real ttys always return 0 from an Fseek, then it can distinguish between them. This might be a more robust scheme than doing the same thing for ttys and pipes (it's the solution I chose for my multitasking system). I presume the dLibs code does something similar, since there was a message from someone (A. Pratt, perhaps?) describing this as the "official" way to do isatty(). -- Eric R. Smith email: Dept. of Mathematics ersmith@uwovax.uwo.ca University of Western Ontario ersmith@uwovax.bitnet London, Ont. Canada N6A 5B7 ph: (519) 661-3638