How to test if a C program on Linux is running from a TTY or not.
This simple C program will test whether it is running from a TTY or not. This is a simple test, but it could be quite useful. #include <stdio.h> #include <poll.h> #include <unistd.h> int main(int argc, char* argv[]){ struct pollfd fds[1] = {{.fd = STDIN_FILENO, .events = POLLIN}}; if (!poll(fds, sizeof(fds) / sizeof(struct … Read more