🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: alt.msdos.programmer
Article #1143

Re: Detecting DOS redirection requests.

#1143
From: Henk den Adel
Date: Sun, 03 Sep 1995 19:01
35 lines
1655 bytes
fritz-o-matic (n4jvp@ix.netcom.com) wrote:
: "David B. Ferguson" <microtsk@fox.nstn.ca> wrote:


: -> How does one tell the user has requested DOS redirection from within
: ->his application. Using C BTW. 

: ->                                  
: Dear David ,
: 	in all cases of command line line redirection, the file assignments
: are changed by the shell, not by the program. The program does not
: know where its input comes from nor where its output goes, so long as
: it uses file 0 for input and 1 and 2 for output. See K&R (2nd edition)
: 7.1 and 8.1 for further details.

: Fritz


You can use the ioctl function. In order to see whether stdin has
been redirected, i use the following code:

int redirected;

redirected = ((ioctl(0,0)&2) == 0);

Check out your library manual to verify the meaning of the zero's. 



Cuagn,
 Henk

----------------------------------------------------------------------------
+  H.denAdel@delftgeot.nl  |  Tel: (+31) 015-693833  |  Fax:  015-610821   +
----------------------------------------------------------------------------
Technical Details
Message-ID: <42cu2b$dk4@mo6.rc.tudelft.nl>
Path: arc1-ca.pugleaf.net!tudelft.nl!dg-sv1!adel
References: <92011.microtsk@fox.nstn.ca> <42bg3q$dr0@ixnews6.ix.netcom.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!tudelft.nl!dg-sv1!adel
From: adel@dg-sv1.delftgeot.nl (Henk den Adel)
Newsgroups: alt.msdos.programmer,comp.lang.c,comp.os.msdos.programmer
Subject: Re: Detecting DOS redirection requests.
Followup-To: alt.msdos.programmer,comp.lang.c,comp.os.msdos.programmer
Date: 3 Sep 1995 19:01:31 GMT
Organization: Delft University of Technology
Message-ID: <42cu2b$dk4@mo6.rc.tudelft.nl>
References: <92011.microtsk@fox.nstn.ca> <42bg3q$dr0@ixnews6.ix.netcom.com>
NNTP-Posting-Host: dg-sv1.delftgeot.nl
X-Newsreader: TIN [version 1.2 PL2]