What Is stdin? The Standard Input Stream
stdin (standard input) is the default stream a program reads incoming data from, usually the keyboard interactively or a file or pipe in scripts.
Every program starts with three standard streams, and stdin is the one it reads from. Interactively, stdin is your keyboard; in a script, it is often a file or the output of another command piped in. In CI, where there is no keyboard, understanding stdin explains why some tools hang waiting for input that never comes.
What stdin is
stdin is file descriptor 0, the channel a process reads input from by default. Functions like read in the shell, or input() in Python, pull from stdin.
Where stdin comes from
At an interactive prompt, stdin is connected to your terminal. In a pipeline, the previous command's output becomes the next command's stdin. With redirection, a file can be fed in as stdin.
Feeding stdin
- A pipe:
cat data.txt | sortsendscatoutput tosortvia stdin. - Redirection:
sort < data.txtreads the file as stdin. - A here-document supplies multiple lines inline as stdin.
Why stdin matters in CI
CI runs non-interactively, so there is no keyboard behind stdin. A tool that prompts for confirmation will hang or read end-of-file. Passing flags like --yes or piping the needed input avoids these hangs.
Closed stdin in CI
In many CI environments stdin is closed or empty, so a read returns immediately. Scripts that assume interactive input must be rewritten to take arguments or environment variables instead.
Managed runners and input
On Latchkey runners, jobs run unattended, so design steps to need no interactive input. Provide values through environment variables, files, or command flags rather than expecting a prompt.
Key takeaways
- stdin is the default input stream, file descriptor 0.
- It can come from a keyboard, a file, a pipe, or a here-document.
- CI is non-interactive, so tools that wait on stdin can hang a job.