fix(cli): Ignore SIGPIPE to prevent crashes on broken pipes - #40
Merged
Merged
Conversation
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.
This PR addresses an issue where the CLI would crash with a SIGPIPE signal when its stdout was piped to another command that exited early (e.g.,
apple-docs ... | head -n 1).The root cause was that the application did not explicitly ignore the SIGPIPE signal. By default, writing to a pipe whose reader has closed results in a SIGPIPE signal, which terminates the process.
The fix involves calling
signal(SIGPIPE, SIG_IGN)inAppleDocs.main()to instruct the operating system to ignore this signal. This ensures that writes to a broken pipe will instead fail with anEPIPEerror, allowing the CLI to exit gracefully without crashing.The
signal(SIGPIPE, SIG_IGN)call is placed aftertelemetry.start()to ensure it takes precedence over any SIGPIPE handler that Sentry's crash reporter might install during its initialization.Fixes APPLE-DOCS-CLI-3
@sentry <feedback>: Autofix iterates on these changes@sentry stop iterating: Autofix stops iterating on this runThis PR was automatically generated by Sentry. You can adjust this setting at any time.