Report a usable error when pty_spawn fails - #9
Open
JohnCampionJr wants to merge 1 commit into
Open
Conversation
A failed spawn reported "pty_spawn failed with error -6: errno -6", which names nothing and is actively misleading -- errno is never negative, so the number is not an errno at all. Two changes. The message now carries all three fields of the result struct and the app that was being spawned, so a failure says what was attempted and what came back rather than one unexplained number. And GetErrorMessage stops guessing. The curated switch covered four errno values and rendered everything else as the bare number, so the failures it could name were the ordinary ones and the interesting ones fell through. Win32Exception maps an errno through strerror on Unix, which names all of them. A non-positive value is called out as not being an errno rather than translated. That distinction is the useful part: errno is never zero or negative, so seeing one means the result struct did not carry what the caller expected, which is a different problem from whatever errno would have described. Getting -6 and having strerror answer "Undefined error: 0" is how an hour disappears. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A failed spawn currently reports:
which names nothing, and is actively misleading — errno is never negative, so that number isn't an errno at all.
Two changes
The message carries all three result-struct fields plus the app being spawned, so a failure says what was attempted and what came back rather than one unexplained number.
GetErrorMessagestops guessing. The curated switch covered four errno values and rendered everything else as the bare number — so the failures it could name were the ordinary ones, and the interesting ones fell through.Win32Exceptionmaps an errno throughstrerroron Unix, which names all of them.A non-positive value is called out as not being an errno rather than translated. That distinction is the useful part: seeing one means the result struct didn't carry what the caller expected, which is a different problem from whatever errno would have described. Getting
-6and havingstrerroranswer"Undefined error: 0"is how an hour disappears.This is the diagnostic half of #7 — that's the bug which produces the
-6, and this is what makes it legible. Independent of it, though; either can go in alone.