At the level, the file descriptor stdin is defined as file descriptor 0 , stdout is defined as file descriptor 1 ; and stderr is defined as a file descriptor 2 . Cm. .
Even if your program or shell changes (for example, redirection with dup2 (2) ), which is a file descriptor of 0, it always remains stdin (since by definition it STDIN_FILENOis 0).
So, of course, stdin can be a pipe or socket or file (and not a terminal). You can test with isatty (3) if it's tty, and / or use fstat (2) to get status information.
Syscalls, (2) pipe (2) socket (2) , , STDIN_FILENO (.. 0), (, (2) -d ). , - .
, stdio (3), FILE stdin . fclose (3), freopen (3), fdopen (3)...
, stdin, stdout stderr , /sbin/init .