Line | |
---|
1 | /* tty.c - Return tty name Author: Freeman P. Pascal IV */
|
---|
2 |
|
---|
3 | /* Minor changes to make tty conform to POSIX1003.2 Draft10
|
---|
4 | Thomas Brupbacher (tobr@mw.lpc.ethz.ch) */
|
---|
5 |
|
---|
6 | #include <sys/types.h>
|
---|
7 | #include <stdlib.h>
|
---|
8 | #include <string.h>
|
---|
9 | #include <unistd.h>
|
---|
10 | #include <stdio.h>
|
---|
11 |
|
---|
12 | _PROTOTYPE(int main, (int argc, char **argv));
|
---|
13 |
|
---|
14 | int main(argc, argv)
|
---|
15 | int argc;
|
---|
16 | char *argv[];
|
---|
17 | {
|
---|
18 | char *tty_name;
|
---|
19 |
|
---|
20 | tty_name = ttyname(STDIN_FILENO);
|
---|
21 | if ((argc == 2) && (!strcmp(argv[1], "-s")))
|
---|
22 | /* Do nothing - shhh! we're in silent mode */ ;
|
---|
23 | else
|
---|
24 | puts((tty_name != NULL) ? tty_name : "not a tty");
|
---|
25 |
|
---|
26 | if (isatty(STDIN_FILENO) == 0)
|
---|
27 | return(1);
|
---|
28 | else
|
---|
29 | return(0);
|
---|
30 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.