Illustration of ‘isatty’ system call in GNU/LINUX

/* Hackintosh rao , codes for GNU/LINUX*/
/* int isatty(fd);
   fd is the file descriptor of a open file
   if the terminal is associated with the file whose Fd is given then ,
   isatty returns 1 , else
   it returns 0
   this system call is used to check whether any open file  with a file descriptor
   is connected to a terminal or not */
int main()
    if(!(isatty(fileno(stdout))))  /*fileno function returns the filedescriptor*/
        write(2,”\n\nstandard o/p not associated with control terminal\n\n”,60);
        /*cannot write into standard output with File descriptor 1 , when the
        terminal is not associated with it , that is when standard o/p is redirected
        using ‘>’ operator when the program is invoked, so the o/p is written into
        standard error with file descriptor 2*/

        printf(“\no/p is associated with the control terminal\n\n”);

    return 0;