coreutils

General Software Utilities
git clone http://git.omkov.net/coreutils
Log | Tree | Refs | README | LICENCE | Download

coreutils/src/tty.c (15 lines, 300 B) -rw-r--r-- blame download

01234567891011121314
// tty.c, version 1.1.0
// OMKOV coreutils implementation of POSIX tty
// Copyright (C) 2020, Jakob Wakeling
// MIT Licence

#include <unistd.h>

#include <stdio.h>

int main(void) {
	char *tty = ttyname(fileno(stdin));
	if (tty) { puts(tty); return 0; }
	else { printf("not a tty\n"); return 1; }
}