jimmy@rlvd.UUCP (Jimmy Aitken) (01/14/85)
I am trying to detect uniquely when one of the following situations occurs in a C program. I have tried isatty(3) but cannot distinguish between a), b), and c) below. Any helpful pointers would be appreciated. a) The standard input has been re-directed in a foreground process b) The standard input has been re-directed in a background process c) No re-direction of standard input in a background process d) No re-direction of standard input in a foreground process
MLY.G.SHADES%MIT-OZ@MIT-MC.ARPA (02/04/85)
actually the way to check for i/o redirection is to compare the stdin / stdout filenames to the stderr filename. i forget the function call at the moment (it's been a while) but the great thing about stderr is that it is supposed to stay the same as the initial stdout throughout a prog. shades@mit-oz.arpa
roy@phri.UUCP (Roy Smith) (02/08/85)
> but the great thing about stderr is that it is supposed to stay > the same as the initial stdout throughout a prog. > shades@mit-oz.arpa Are we forgetting the 4.2 ">&" which redirects both stdout and errout? -- The opinions expressed herein do not necessarily reflect the views of the Public Health Research Institute. allegra!vax135!timeinc\ cmcl2!rocky2!cubsvax>!phri!roy (Roy Smith) ihnp4!timeinc/