I don't think that you're guaranteed to get the right stdin when running directly from a non-interactive shell, or have any stdin mechanism at all.
Here's what you can try :
Execute fcntl(stdin, F_GETFD) and check errno.
Check the return value of tcsetattr. There's no guarantee it won't fail.
Try the raw mode:
cfmakeraw() sets the terminal to something like the "raw" mode of the
old Version 7 terminal driver: input is available character by charac-
ter, echoing is disabled, and all special processing of terminal input
and output characters is disabled. The terminal attributes are set as
termios_p->c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP
| INLCR | IGNCR | ICRNL | IXON);
termios_p->c_oflag &= ~OPOST;
termios_p->c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN);
termios_p->c_cflag &= ~(CSIZE | PARENB);
termios_p->c_cflag |= CS8;
Finally, fprintf(stderr, message_format, ...) is preferred for logging, as, by default, stdout is buffered and might not display anything until a '\n' character is read. stderr is not buffered, and therefore do not have such issues.
See http://man7.org/linux/man-pages/man3/stdout.3.html for more details
I'll see if I can create a little example showing how to grab keyboard inputs with Evdev.