isatty checks tty, not the pipe. Use fstat(STDIN_FILENO, &sb) S_ISFIFO(sb.st_mode) and check S_ISFIFO(sb.st_mode) .
To check if there is anything "in" stdin that you could read, you use, for example, poll(2) with the POLLIN event POLLIN .
source share