#include <sys/types.h> #include <unistd.h> char *ttyname(int fn);
ttyname
returns the name of the OpenEdition 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 OpenEdition
terminal.
ttyname
returns the name of the terminal if it is successful
and a NULL pointer if it is not successful.
ttyname
may overwrite the terminal name
string.
#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 %sn", name); } name = ttyname(STDOUT_FILENO); if (name) { ++count; printf("The standard output is a terminal file named %sn", name); } name = ttyname(STDERR_FILENO); if (name) { ++count; printf("The standard error output is a terminal file named %sn", name); } if (!count) puts("None of the standard files is a terminal file."); return 0; }
ctermid
Copyright (c) 1998 SAS Institute Inc. Cary, NC, USA. All rights reserved.