Path: utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!usc!ucsd!ucbvax!bloom-beacon!eru!hagbard!sunic!ericom!eos.ericsson.se!epames From: epames@eos.ericsson.se (Michael Salmon) Newsgroups: comp.lang.c Subject: Re: Redirection question Message-ID: <1990Nov13.073315.2831@ericsson.se> Date: 13 Nov 90 07:33:15 GMT References: Sender: news@ericsson.se Reply-To: epames@eos.ericsson.se Organization: Ericsson Telecom AB Lines: 17 In article roarment@faui09.informatik.uni-erlangen.de (Roberto Armenti) writes: >Is there a _portable_ way to recognize whether input comes from >stdin or from another stream ? > >The solution should at least work on UNIX _AND_ MS-DOS, so i'm looking for >a _portable_ implementation. isatty(fileno(stdin)) should do what you want. I have seen it implemented on Unix, MS_DOS and CP/M systems but I can't say how portable it is. I also find it very handy to determine when to give a usage message when file names are omitted from the command line, I hate programmes that do nothing when I make a mistake. Michael Salmon L.M.Ericsson Stockholm