🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.msdos.programmer
Article #5765

Sensing STDOUT redirection in C

#5765
From: Adrian Collins
Date: Mon, 15 Apr 1991 13:11
19 lines
1397 bytes
I am currently writing a program for the PC using C.  I need to be able
to sense whether STDOUT has been redirected on the command line.  In the
case where the output has not been redirected the program opens a text
window and displays the info in that window, but if output redirection
was used I want the program to output to STDOUT as it should assume that
the output is to be sent to a file.

Does anybody know how to sense whether output redirection has been used
on the command line?

Adrian

---
Adrian Collins                              collinsa@uk.ac.man.cs.p4
Department of Computer Science              a.m.collins@uk.ac.mcc
University of Manchester
Manchester,                                 "Let me face the peril"
UK.                                         "No, it's too perilous!"
                                                    - The Holy Grail
Technical Details
Message-ID: <collinsa.671721083@p4.cs.man.ac.uk>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!samsung!olivea!mintaka!bloom-beacon!eru!kth.se!sunic!mcsun!ukc!mucs!p4.cs.man.ac.uk!collinsa

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!samsung!olivea!mintaka!bloom-beacon!eru!kth.se!sunic!mcsun!ukc!mucs!p4.cs.man.ac.uk!collinsa
From: collinsa@p4.cs.man.ac.uk (Adrian Collins)
Newsgroups: comp.os.msdos.programmer,comp.lang.c
Subject: Sensing STDOUT redirection in C
Keywords: STDOUT, Redirection, MSDOS
Message-ID: <collinsa.671721083@p4.cs.man.ac.uk>
Date: 15 Apr 91 13:11:23 GMT
Sender: news@cs.man.ac.uk
Followup-To: comp.os.msdos.programmer
Lines: 19