sbase

suckless unix tools
git clone git://git.suckless.org/sbase
Log | Files | Refs | README | LICENSE

tty.c (409B)


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