[net.micro.pc] Am I in a pipe?

starr@shell.UUCP (Bob Starr) (08/15/84)

Does anyone know how to tell (within a program) if stdin and/or stdout
are under redirection or pipes?

I have seen this in UNIX, and figure there *must* be a way under MS-DOS,
since it represents a "smooth bridge to UNIX"!

Thanks,
Bob Starr

jcw@cvl.UUCP (Jay C. Weber) (08/16/84)

Since in DOS 2.0 there is no difference between a pipe and redirection,
(except that pipe file names follow the %PIPEx.$$$ convention) you
can't tell the difference in a program, but you can tell whether
either stdin or stdout has been redirected through the IOCTL (int 21/44)
call [DOS manual, d-39].  Just do a get device information call on
file handles 0 and 1, and look at the ISDEV bit on each.  If it is 0,
you know it has been redirected.  To distinguish whether i/o has
been sent to another device, with ISDEV=1 look at ISCOT (is console
output) and ISCIN (is console input).

Jay Weber
..!seismo!rlgvax!cvl!jcw
jcw@cvl.arpa
..!seismo!rochester!jay
jay@rochester.arpa