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

Miscellaneous Linux commands. Some useful tips for the Linux BASH prompt.

The ldd command will print out a list of all libraries that an executable is linked against. This is the output for a simple “Hello World” command. 20:15:31 tux@linux-v415 ($ ldd ./a.out linux-vdso.so.1 =&gt; (0x00007fff171ff000) libc.so.6 =&gt; /lib64/libc.so.6 (0x00007fe56ef58000) /lib64/ld-linux-x86-64.so.2 (0x00007fe56f2e8000) 20:15:49 tux@linux-v415 ($20:15:31 tux@linux-v415 ($ ldd ./a.out linux-vdso.so.1 =&gt; (0x00007fff171ff000) libc.so.6 =&gt; /lib64/libc.so.6 (0x00007fe56ef58000) … Read more