Does each process have its own stdin, stdout and stderr?

Each process has its own stdin, stdout and stderr or do they just share 1 stdin, 1 stdout and 1 stderr? I mean, of course, as a rule, 1 keyboard and 1 terminal for each computer, but the input and output streams of processes are separated from each other?

+6
source share
1 answer

stdout , stdin and stderr are just abstractions given to the process by the operating environment for interacting with its inputs and outputs. Despite the fact that in any case there is only one keyboard (in most cases), the operating system knows how to decide which process receives the current input and passes keystrokes to stdin this process. Similarly, despite having only one screen, it can be split into multiple windows. Finally, many processes have their own input and output, tied to a file stream. Operating systems can associate several processes with one input or with one output file, but even in this case, the objects representing the stdin and stdout streams inside the process will be separate: they will refer to the same object in the operating system, and the OS will control sharing this object among its users.

+10
source

Source: https://habr.com/ru/post/922353/


All Articles