source: trunk/minix/commands/simple/tty.c@ 15

Last change on this file since 15 was 9, checked in by Mattia Monga, 14 years ago

Minix 3.1.2a

File size: 646 bytes
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
14int main(argc, argv)
15int argc;
16char *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.