Unix to Windows Porting Dictionary for HPC

Links

Function List

isatty


Unix

header file: unistd.h

int isatty(int fd);

Windows

header file: io.h

int _isatty(int fd);

Purpose

This function tests whether the file descriptor fd is associated with terminal device.

Discussion

Since this function has a direct analog in Windows, the only changes that should be needed are to rename the function in your source code, and include the needed Windows header file.

Example of Use in Windows

#include <io.h>

if (_isatty(_fileno(stdout)))
  printf("stdout has not been redirected.");
else
  printf("stdout has been redirected.");
  
blog comments powered by Disqus