I have read books/tutorials which mention standard input/output/error. My understanding is that:

  1. standard input/output/error are concepts of a process (i.e. if someone mentions standard input/output/error, they are actually talking about standard input/output/error of a particular process. It doesn't make sense to talk about standard input/output/error of a file.)
  2. Standard input in Linux for most processes is keyboard and standard output/error is screen.

My question: if there's the standard, what is the non-standard input/output/error of a process in Linux?


The file descriptors 0, 1, and 2 are provided by default when a process is execed, and associated with stdin, stdout, and stderr. If a process needs additional I/O channels, it opens non-standard file descriptors starting from 3.

For 1.: Yes

For 2.: That's true for interactive processes whose I/O is not redirected. Other processes (e.g. cron jobs) can well have different associations.

  • 2
    For 2, I'd say that is a result of "most processes" being started from a shell whose own standard file descriptors are a terminal. All processes inherit the standard file descriptors from their parent. (Even redirections are instructions to the shell to substitute other descriptors in place of the shell's own. A process is unaware of how its own standard descriptors are set.) – chepner Sep 28 '18 at 13:12
  • Indeed, for 2 it's only the case that they are normally whatever the process inherits from its parent, which, for a command typed in an interactive session, will be the interactive device. Plenty of processes are started in contexts nothing like that. – R.. GitHub STOP HELPING ICE Sep 30 '18 at 19:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.