I'm trying to duplicate the code in bash/test that checks that stdout is 
a "terminal". Compiling and running the following:

#include <stdio.h>
#include <io.h>
int main( int ac, char **av ) {
   printf( "isatty(stdout): %s\n", isatty( fileno(stdout) )? "yes" : "no" );
}

returns "no" when run in mintty but "yes" for cmd|tcc.

If I run bash or test from cmd|tcc, -t returns true >and< it returns 
true when run from mintty.

I've downloaded the source for coreutils and bash but I can find nothing 
that appears in any way special.

I noticed that ldd /usr/bin/test loads msys-2.0.dll while my program 
above loads msvcrt.dll

Could that be the difference? If so, how would I compile&link my sample 
program against msys-2.0.dll?

Or my real question: how can I tell if stdout is redirected or the 
"terminal" from within a program?


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Msys2-users mailing list
Msys2-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/msys2-users

Reply via email to