this post was submitted on 05 Oct 2024
10 points (100.0% liked)

Bash

722 readers
1 users here now

Talk about the Bash Shell and Bash scripting

founded 4 years ago
MODERATORS
top 3 comments
sorted by: hot top controversial new old
[–] [email protected] 8 points 1 month ago (1 children)

They are file handles. All three are opened by default for all new processes.

STDIN is number 0 STDOUT is number 1 STDERR is number 2

By default STDIN is connected to a buffer which keyboard chars are put in by the OS.

STDOUT is a buffer read by your terminal emulator to be drawn on the screen if it's a GUI. A raw terminal does the same, but without the windows manager layer in the middle. Essentially, the virtual terminal is reading the STDIO buffer and rendering the characters to it's GUI windows for you.

STDERR is the same as STDIO, but is usually only used for error messages, but they're displayed via a different file handles so they can be captured and redirected separately from STDIO.

[–] [email protected] 3 points 1 month ago (1 children)

Thank you. Article kept referring to them as "streams" which is meaningless in the context of Linux. Writing this article without describing or even mentioning file handles is a disservice.

[–] [email protected] 2 points 1 month ago

Really? C++ uses the word stream to refer to abstractions that are buffers for reading/writing (depending permission).

How would files and streams differ in that case?

I guess you're saying file handles can be pointing to memory instead of storage but I always think of the word "file" for data written to storage instead of ram. What makes it meaningless in the context of Linux?