开发者

Does GUI program need Standard Streams?

开发者 https://www.devze.com 2022-12-21 03:16 出处:网络
I read 开发者_运维技巧about standard streams. My understanding is old fashioned programs that don\'t have GUI need some kind of user interface, too. So Operating System provide each of them with a con

I read 开发者_运维技巧about standard streams. My understanding is old fashioned programs that don't have GUI need some kind of user interface, too. So Operating System provide each of them with a console window, and the console window's out/input/err stream was mapped to the program's standard input/output/error stream. And thus these programs are called console application. And this mappings couldn't be modified by the programmer.

I am wondering, if my understanding above is correct, does GUI program have these standard streams also? I don't think it's necessary since GUI itself is a good user interface.


I'm quoting the bottom of the article you linked to:

Graphical user interfaces (GUIs) rarely make use of the standard streams.

Some GUI programs, primarily on Unix, still write debug information to standard error.

Others may take files to operate from standard in, for example many Unix media players do so.

Therefore from the above quotes, you can see that yes they do, although they're rarely used.

"And this mappings couldn't be modified by the programmer."

This is incorrect - certainly on UNIX they can be - not sure about Windows. For example, you can close the standard output stream and redirect it to a file stream to get the output written to a file.


  • This varies a lot based on your OS. Some will create a console if you run a "command line" app, some will connect the standard streams to the same streams as the process that started the program had.
  • You typically can change the stdout/in/err streams, it's very common to connect them to something else than the console in which they were run, like a pipe or file.
  • GUI programs typically have the stdout/err/in streams as well.
  • GUI programs rarly use those streams, perhaps except for debugging printfs during development.
  • GUI programs might redirect those streams to /dev/null or something similar that just discards data written to it.
0

精彩评论

暂无评论...
验证码 换一张
取 消