- c - Do stdio file descriptors (stdin, stdout, stderr) get opened, simply from #include'ing <stdio.h>? - Stack Overflow
- standard streams of a program are opened by the operating system? or, inherit from its parent (, which inherit from its ancestor who opens these standard streams).
- initialization - execute
- initialization: loading symbol tables, assigning memory, initializing static data, linking dynamic libraries, open standard streams.
- execute: main() function
- fork() - exec():
- fork(): to create a new process, which is still running under shell code.
- exec(): to yield control from shell code to user code.
- (standard) file descriptors 0, 1, and 2 (or more customer ones)
- file - What does 'stream' mean in C? - Stack Overflow
- file & stream.
- 文件-静态,流-(input/流入、output/流出间可)异步动态。
- pipe / tube / flow. cache / buffer / pool/池。
- 具象的files, sockets, device (keyboards, USB ports, printers),抽象为接口/interface,logical entity,称为数据流/data stream 。
- 此抽象亦叫做文件句柄——pointer to the stream.
- cout 是C++中的output stream的对象(封装)形式。
- Standard streams - Wikipedia
In computer programming, standard streams are interconnected input and output communication channels[1] between a computer program and its environment when it begins execution. The three input/output (I/O) connections are called standard input (stdin), standard output (stdout) and standard error (stderr). Originally I/O happened via a physically connected system console (input via keyboard, output via monitor), but standard streams abstract this. When a command is executed via an interactive shell, the streams are typically connected to the text terminal on which the shell is running, but can be changed with redirection or a pipeline. More generally, a child process inherits the standard streams of its parent process.
-
- 结论,效果无益
- FileStream / MemoryStream.
- disk accesses / paging
- FileStream constructor
- Temp directory: something like C:UsersUserNameAppDataLocalTemp , from environment variable TMP - TEMP -USERPROFILE - ..
- python - How to do virtual file processing? - Stack Overflow
tempfile.SpooledTemporaryFile(python)
- StringIO , BytesIO(python)
- File system - Wikipedia
- Console Handles - Windows Console | Microsoft Docs
A console process (not all process) uses (standard) handles.
-
- process associate with console.
- console有input buffer, output (screen) buffer (console output)。可以通过 CreateFile +CONIN$ /CONOUT$获取。
- console proccess有STDIN, STDOUT等。默认继承自父。可以通过 SetStdHandle 改变。
-
- GetStdHandle , CreateFile , CreateConsoleScreenBuffer
The standard handles associated with a process.
During console creation, the system creates these handles.
The parent's standard handles are inherited by any child process
The value of the handles returned by GetStdHandle are not 0, 1, and 2, so the standard predefined stream constants in Stdio.h ( STDIN , STDOUT , and STDERR ) cannot be used in functions that require a console handle.
-
- std handle initial associate to console buffer.
- SetStdHandle redirect/重定向
- CreateFile +CONIN$ /CONOUT$ (CON: Console, Create: Retrieve the exist)
- CreateConsoleScreenBuffer - SetConsoleActiveScreenBuffer
GetFileTypecan assist in determining what device type the handle refers to
-
- DuplicateHandle - AttachConsole
- 开发GUI程序时同时打开一个控制台窗口进行调试多么惬意啊 - MudooT - 博客园
- 为非Console进程建立Console进程并关联。
- 使用AllocConsole() 建立Console,使用open+conin$/conout$获取Console中的输入/输出句柄,进而可以进行输入/输出访问操作(关联)。
- open - close(句柄);alloc - free(Console)。
- 以上我新建Console,除此,可以使用AttachConsole附加到已有。
- GetStdHandle function - Windows Console | Microsoft Docs
standard device (standard input, standard output, or standard error).
-
- an application (such as running on an interactive desktop) may not have associated standard handles.
- ReadConsoleInput , WriteConsole , GetConsoleScreenBufferInfo ; CreateFile + CONIN$ /CONOUT$ 。
- GUI(graphical user interface)可使用 AttachConsole , AllocConsole , FreeConsole 建立console交互。
- 使用 GetFileType 检查继承到的标准输入输出/STDIO。
- LuaFileSystem
- lfs.lock lfs.unlock
- 随想:
- 一个字符串也算一个对象、数据流。
- 元数据/属性为(主)数据基于描述系统(如文件系统)的,相对于主数据的附属数据。
- 考虑:
- (基于内存的)虚拟文件对象/流;->效果无益
- 公共文件对象/流;->见下
- Lua中的io.tmpfile() 。
- 搜索:
A console process uses handles