Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!ucbvax!unisoft!bdt!david From: david@bdt.UUCP (David Beckemeyer) Newsgroups: comp.sys.atari.st.tech Subject: MicroRTX patch and isatty() fix Keywords: RTX multitasking Message-ID: <4352@bdt.UUCP> Date: 13 Aug 90 21:14:15 GMT Organization: Beckemeyer Development Tools Lines: 110 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). So what I propose is that the isatty() code should be changed to first check to see if RTX is running, and use the more reliable RTX calls to see if the handle is a tty. The following will work whether RTX is running or not: ======== CUT HERE for new isatty code ======== #define Ftype(x) gemdos(0x101, x) isatty(fd) int fd; { int fd_type; /* * First use RTX Ftype() to get the handle type. * * If RTX isn't running this call will return -32 * (invalid function), and so we will just skip to * the old isatty() for regular old GEMDOS. * * If RTX is running, then Ftype() tells us what the * handle really is: * 0-15 The BIOS device number (tty) * 16 File * 17 Pipe */ fd_type = Ftype(fd); if (fd_type >= 0) return(fd_type < 16); /* * The old isatty() code... */ [ Place your favorite isatty() code here ] ======== END OF NEW isatty() code ======== Below is the start of the program that will patch RTX V1.13 so that Fseek() will return zero on non-seekable handles which helps current isatty() library code work with RTX (the better solution is to fix the isatty() code as shown above). Use this program from a command line. Change directory to where the RTXBOOT.PRG file is and type "rtxpatch". It modifies the RTXBOOT.PRG (so save a copy if you're worried). begin 644 rtxpatch.prg M8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