Article View: comp.os.msdos.programmer
Article #1817Re: How to detect redirection?
From: Duncan Murdoch
Date: Wed, 08 Aug 1990 13:48
Date: Wed, 08 Aug 1990 13:48
35 lines
1984 bytes
1984 bytes
In article <1990Aug8.004304.26989@Octopus.COM> stever@octopus.UUCP (Steve Resnick ) writes:
>that character may already be on the screen. In C the easiest way to determine
>if I/O has been redirected is to call isatty(fileno(stdout)) this returns
>non-zero if the file descriptor associated with stdout is a character device.
>The problem with this is the redirection may be associated with another
>character device (AUX, PRN, etc). Is there an easy way to do THIS?
Use the IOCTL service from DOS. To quote Ralf Brown's interrupt list:
INT 21 - DOS 2+ - IOCTL - GET DEVICE INFORMATION
AX = 4400h
BX = file or device handle
Return: CF set on error
AX = error code (see AH=59h)
CF clear if successful
DX = device info
If bit 7 set: (character device)
1: console output device
2: NUL device
3: CLOCK$ device
4: device is special (uses INT 29)
5: binary (raw) mode
6: Not EOF
12: network device (DOS 3+)
14: can process IOCTL control strings (see AL = 02h-05h)
If bit 7 clear: (file)
bits 0-5 are block device number
6: file has not been written
12: network device (DOS 3+)
14: can process IOCTL control strings (DOS 3+)
15: file is remote (DOS 3+)
SeeAlso: AX=4401h, INT 2F/AX=122Bh
Duncan Murdoch
Technical Details
Message-ID:
<1990Aug8.134837.4637@maytag.waterloo.edu>Path:
arc1-ca.pugleaf.net!utzoo!attcan!uunet!mailrus!iuvax!maytag!watstat!dmurdochReferences:
<1426@wet.UUCP> <1990Aug8.004304.26989@Octopus.COM>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!mailrus!iuvax!maytag!watstat!dmurdoch From: dmurdoch@watstat.uwaterloo.ca (Duncan Murdoch) Newsgroups: comp.os.msdos.programmer Subject: Re: How to detect redirection? Message-ID: <1990Aug8.134837.4637@maytag.waterloo.edu> Date: 8 Aug 90 13:48:37 GMT References: <1426@wet.UUCP> <1990Aug8.004304.26989@Octopus.COM> Sender: daemon@maytag.waterloo.edu (Admin) Organization: University of Waterloo Lines: 35