Detecting console output

Dave Smith dave at
Fri Feb 19 17:51:30 MST 2010

How can I tell, in Linux in C, whether stdout and stderr are redirected 
to a file vs. an interactive shell? I tried playing with stat(2) and the 
st_mode, but I'm not getting the results I expect.



P.S. I'm doing this because I want to disable colors if my output is 
going to a file, but enable colors if it's a shell.

More information about the PLUG mailing list