Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggest for change the order of the creation of the standard streams in cpu_start #67

Closed
jolivepetrus opened this issue Oct 31, 2016 · 1 comment
Assignees

Comments

@jolivepetrus
Copy link

I suggest to change the order of the creation of the standard streams in cpu_start:

current order:
_GLOBAL_REENT->_stdout = fopen(default_uart_dev, "w");
_GLOBAL_REENT->_stderr = fopen(default_uart_dev, "w");
_GLOBAL_REENT->_stdin = fopen(default_uart_dev, "r");

proposed order:
_GLOBAL_REENT->_stdin = fopen(default_uart_dev, "r");
_GLOBAL_REENT->_stdout = fopen(default_uart_dev, "w");
_GLOBAL_REENT->_stderr = fopen(default_uart_dev, "w");

The thing is that with the current order the correspondence between standard streams and standards file descriptors are incorrect:

_stdout has file descriptor 0
_stderr has file descriptor 1
_stdin has file descriptor 2

and the correct file descriptors are:

_stdin has file descriptor 0
_stdout has file descriptor 1
_stderr has file descriptor 2

In posix-compliance code this will be a problem wen using functions that work with file descriptors, such as write, for example:

write(STDOUT_FILENO, "hello world", 11)

will out to STDERR.

@igrr igrr self-assigned this Nov 7, 2016
igrr added a commit that referenced this issue Nov 9, 2016
With existing order, file descriptors assigned to stdin, stdout, stderr didn't match standard assignment.
#67
@igrr
Copy link
Member

igrr commented Nov 9, 2016

Fixed master

@igrr igrr closed this as completed Nov 9, 2016
igrr pushed a commit that referenced this issue Mar 11, 2019
tools: re-run idf.py in MSYS with winpty

Closes #67

See merge request idf/esp-idf!4341
mikkeldamsgaard pushed a commit to mikkeldamsgaard/esp-idf that referenced this issue Sep 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants