![]() Chapter Contents |
![]() Previous |
![]() Next |
| ttyname |
| Portability: | POSIX.1 conforming, UNIX compatible |
| SYNOPSIS | |
| DESCRIPTION | |
| RETURN VALUE | |
| CAUTION | |
| EXAMPLE | |
| RELATED FUNCTIONS | |
| SEE ALSO |
| SYNOPSIS |
#include <sys/types.h> #include <unistd.h> char *ttyname(int fn);
| DESCRIPTION |
ttyname
returns the name of the USS terminal associated with the file descriptor
fn
. The
ttyname
function returns
NULL
if the file descriptor
is not open, or if it does not refer to an USS terminal.
| RETURN VALUE |
ttyname
returns the name of the terminal if it is successful and a NULL pointer if
it is not successful.
| CAUTION |
Subsequent calls to
ttyname
may overwrite the terminal name string.
| EXAMPLE |
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
main() {
char *name;
int count = 0;
name = ttyname(STDIN_FILENO);
if (name) {
++count;
printf("The standard input is a terminal file named %s\n",
name);
}
name = ttyname(STDOUT_FILENO);
if (name) {
++count;
printf("The standard output is a terminal file named %s\n",
name);
}
name = ttyname(STDERR_FILENO);
if (name) {
++count;
printf("The standard error output is a terminal file named %s\n",
name);
}
if (!count)
puts("None of the standard files is a terminal file.");
return 0;
}
| RELATED FUNCTIONS |
| SEE ALSO |
![]() Chapter Contents |
![]() Previous |
![]() Next |
![]() Top of Page |
Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.