morpheus-base

morpheus base system
git clone git://git.2f30.org/morpheus-base
Log | Files | Refs

tty.c (376B)


      1 /* See LICENSE file for copyright and license details. */
      2 #include <stdio.h>
      3 #include <stdlib.h>
      4 #include <unistd.h>
      5 
      6 #include "util.h"
      7 
      8 static void
      9 usage(void)
     10 {
     11 	eprintf("usage: %s\n", argv0);
     12 }
     13 
     14 int
     15 main(int argc, char *argv[])
     16 {
     17 	char *tty;
     18 
     19 	ARGBEGIN {
     20 	default:
     21 		usage();
     22 	} ARGEND;
     23 
     24 	tty = ttyname(STDIN_FILENO);
     25 	puts(tty ? tty : "not a tty");
     26 	return tty ? 0 : 1;
     27 }