-
-
Notifications
You must be signed in to change notification settings - Fork 398
Fix tools tty detection (fix avrdude running in safe mode) #897
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
Conversation
They are immediatly overwritten on the next line.
This is required because some tools detects if the program is running from terminal by looking at the stdin/out bindings. Fix: arduino#844
If running with safemode is the problem here, wouldn't a cleaner fix be to run avrdude with Looking at the code, this adds custom readers and writers to create null streams, which seems rather inefficient to me (since it involves creating an extra pipe pair underwater, I think). A simpler way would be to just set .e.g |
yes, that's the problem, adding
I tried that, but they are |
Hm, good point. In the original report @per1234 mentions this problem occurs on Windows and Linux/Ubuntu, but you're only mentioning Windows here. I also tried reproducing it (with your testcode, not full arduino-cli) on Ubuntu, but there it seems to work as expected (istty returning false for Looking at the golang which on windows is just a special file called So that sounds like it should work. Maybe This post suggests that the "64 return value for NUL" is actually the case with It seems that the ideal fix for this would maybe be in mingw, which would then be used to recompile a fixed avrdude. However, that's quite complicated, so maybe your solution is indeed the easiest way forward. I do wonder if this redirection needs to happen for stdout/stderr as well (seems to be overridden in practice), maybe just keep the hack as small as possible and only apply it for stdin? One alternative could be to simply close stdin rather than redirect it to /dev/null, which I think would also make |
Sorry, I think my report was unclear. When I said this:
I meant running the |
This is not strictly required for the 'avrdude' hack.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some tools detects if the program is running from terminal by looking at the stdin/out bindings.
Previously stdin wasn't bound to any custom stream, this fact lead
avrdude
to think it was run from terminal (instead of a script) and start it in "safe-mode". This turn out to be a problem in some cases, see #844From the avrdude source code:
So we need to ensure that
isatty(STDIN_FILENO)
returns0
when we run tools.I've tried to run the following test program:
compiled with:
and
using the following launcher in go:
I tried with and without the
cmd.Stdin = inStream
:cygwin
build is unaffected it always returns0
mingw32
build instead returns64
without the stdin redirect and0
with the stdin redirect.This makes me think that
avrdude
has been built withmingw32
and this PR should fix the issue, but a direct test is required.Fix: #844