sbase

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

tty.c (420B)


      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 	argv0 = *argv, argv0 ? (argc--, argv++) : (void *)0;
     19 
     20 	if (argc)
     21 		usage();
     22 
     23 	tty = ttyname(STDIN_FILENO);
     24 	puts(tty ? tty : "not a tty");
     25 
     26 	enfshut(2, stdout, "<stdout>");
     27 	return !tty;
     28 }