emscripten-core / emscripten-core/emscripten

Move stdout and stderr line buffering responsibility to shell.html

Open
#5,290 34 comments 4 reactions 0 assignees View on GitHub
filesystem
Dominant language
C++
Stars
27.6k
Forks
3.6k
Avg merge
1d 1h
Merged PRs (30d)
105

Description

Something I've been thinking of doing for quite a while - currently we expect that stdout and stderr streams are line buffered (e.g. like `console.log()` is) by requirement, and for example on `fflush()` we can only flush full lines. However different environments have support for different granularities. For example:
- we can flush individual characters when printing to a text box on a web page, so that does not need to depend on line buffering
- when one is using `window.dump()` to debug, then we would be able to support char buffering
- when one is using emrun debug harness, then we can support char buffering
- when one is using a shell like node.js or SpiderMonkey, then we can also do char buffering

It would make sense to remove the abstractions for line buffering and rebuild them in the default shell.html file instead. That would allow a clean way to fix #2770.

The only drawback is for people who use a custom shell file, if behavior changed on them to suddenly buffer chars instead of lines, then they would see incorrectly split `console.log()` prints. Therefore the feature would perhaps need to be an option that one opts in to.

Any objections?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.