Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!ukma!rutgers!bellcore!wind!tr
From: tr@wind.bellcore.com (tom reingold)
Newsgroups: comp.sys.ibm.pc
Subject: Re: How to determine stdin/out redirection
Message-ID: <10479@bellcore.bellcore.com>
Date: 26 Sep 88 19:51:35 GMT
References: <9465@cup.portal.com>
Sender: news@bellcore.bellcore.com
Reply-To: tr@wind.UUCP (tom reingold)
Organization: Bellcore, Morristown, Noo Joizy
Lines: 19

In article <9465@cup.portal.com> Steve_R_Calwas@cup.portal.com writes:
$ 
$ One quick question:
$ 
$ Is there a way for an application program to determine whether or not its
$ standard input and/or standard output are being redirected?

If you are using a C compiler, you can use the isatty() function
which says if something is a tty.  If not, then it's being redirected.

This is is not a read-the-f_cking-manual reminder since I suspect
you didn't know about the existance of isatty() until now.  Now
that you do, I am sure you will enjoy reading all about it.

Tom Reingold
PAPERNET:                      |INTERNET:       tr@bellcore.bellcore.com
Bell Communications Research   |UUCP-NET:       bellcore!tr
445 South St room 2L350        |SOUNDNET:       (201) 829-4622 [work],
Morristown, NJ 07960-1910      |                (201) 287-2345 [home]