• azimir@lemmy.ml
    link
    fedilink
    English
    arrow-up
    8
    ·
    1 month ago

    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.

    • bruhbeans@lemmy.ml
      link
      fedilink
      English
      arrow-up
      3
      ·
      1 month ago

      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.

      • _____@lemm.ee
        link
        fedilink
        English
        arrow-up
        2
        ·
        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?