[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ Manuals ]


isatty

Determine a specified file_id

Compatibility:

This function is compatible with the following targets:

ANSI

BeOS

EMB/RTOS

Mac OS

Palm OS

Win32


Prototype:
#include <unistd.h>
int isatty(int fildes);
Parameters:

Parameters for this facility are:

fildes  
int  
The file descriptor  

Remarks:

The function isatty() determines if a specified file_id is attached to the console, or if re-direction is in effect. Example of usage is given in "Example of isatty() ttyname() usage."

Return:

isatty() returns a non-zero value if the file is attached to the console. It returns zero if Input/Output redirection is in effect.

See Also:

"ccommand"

Example of isatty() ttyname() usage.:
#include <console.h>
#include <stdio.h>
#include <unistd.h>
#include <unix.h>

int main(int argc, char **argv) 
{
	int i;
	int file_id;
   argc = ccommand(&argv);
   
   file_id = isatty(fileno(stdout));
   if(!file_id )
   {
	for (i=0; i < argc; i++)
		printf("command line argument [%d] = %s\n",
		      i, argv[i]);
	}
	else printf("Output to window");
	
	printf("The associated terminal is %s",
	      ttyname(file_id) );

	return 0;
}

Result if file redirection is chosen using the command line arguments
Metrowerks CodeWarrior. 
Written to file selected:
 
command line argument [0] = CRef
command line argument [1] = Metrowerks
command line argument [2] = CodeWarrior
The associated terminal is SIOUX


[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ Manuals ]

Visit the Metrowerks website at: http://www.metrowerks.com
For assistance contact Metrowerks Technical Support at: cw_support@metrowerks.com
Copyright © 2000, Metrowerks Corp. All rights reserved.

Last updated: August 16, 2000