stdin stdout stderr

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
pepito

stdin stdout stderr

Post by pepito »

Hello:

I want to add to my OS the stdin/stdout/stderr streams, but I have a doubt about at which level these streams must be open.

I can see two possibilities:

1) At kernel level: In this case all process share the same stdin/stdout/stderr streams.

2) When the process is created: In this case each process have its own stdin/stdout/stderr streams.

I am really lost about this subject, any information to be grateful.
I am looking too for information about how Linux do it (some book or link).

Thank you very much,

pepito
Another Stupid Coder

RE:stdin stdout stderr

Post by Another Stupid Coder »

I would make it at kernellevel so that every process can use the same stream but i'm really NO expert.
carbonBased

RE:stdin stdout stderr

Post by carbonBased »

I would agree, and make a form of abstraction to make it *appear* that each process has its own stdin/out/err... probably through some form of virtual console... these can be directed to the *real* screen via a linux-like ALT-F?, or directed to separated windows ala x11, etc.

--Jeff
pepito

RE:stdin stdout stderr

Post by pepito »

Thank you!

But, how a virtual console works?

pepito
Fitz

RE:stdin stdout stderr

Post by Fitz »

I don't really know what I'm talking about.  That said:

If I was writing the virtual console, I would give each virtual console its own buffer of stdin memory.  If you run the process in the forground, that process's stdout data is mapped to the vitual console's stdin buffer.  Likewise, you can map the stdout to append to a file instead of a virtual console's buffer.  For a process running in the background, you would have to have the stdout data get mapped somewhere, possibly a file or a stdin buffer for another process.

Then when the user changes virtual consoles, it can be a matter of telling the video driver (a process running in the background?) to use the data at a different place in memory to draw to the screen.  I guess you might say that it is changing the video driver's stdin buffer to point to or read from another virtual console's stdout buffer.

But again, all of this is off the top of my head.  I don't really know what Linux or other operating systems do.
Fitz

RE:stdin stdout stderr

Post by Fitz »

Something I would like to add:

Maybe these stdin and stdout buffers are shared memory since the stdout of one process can be the stdin of another process.
Post Reply