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

Add a function on LocalFileOutputByteStream to disable SIGPIPE when writing data to it after the receiving end is closed #502

Merged
merged 1 commit into from
Mar 28, 2025

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented Mar 28, 2025

Without this, if we launch a subprocess and try to write data to its stdin after it has finished (or crashed), we would take down the current process due to the SIGPIPE, which is usually not desirable. Eg. SourceKit-LSP doesn’t want to exit with a SIGPIPE exit code if a launched swift-format subprocesses crashes before the file to format could transferred to its stdin.

This mirrors behavior of DispatchIO, which also doesn’t emit a SIGPIPE when trying to write data to a stream whose receiving end has closed.

This will be used by swiftlang/sourcekit-lsp#2098.

…en writing data to it after the receiving end is closed

Without this, if we launch a subprocess and try to write data to its stdin after it has finished (or crashed), we would take down the current process due to the SIGPIPE, which is usually not desirable. Eg. SourceKit-LSP doesn’t want to exit with a SIGPIPE exit code if a launched swift-format subprocesses crashes before the file to format could transferred to its stdin.

This mirrors behavior of `DispatchIO`, which also doesn’t emit a `SIGPIPE` when trying to write data to a stream whose receiving end has closed.
@ahoppen
Copy link
Member Author

ahoppen commented Mar 28, 2025

@swift-ci Please test

@ahoppen
Copy link
Member Author

ahoppen commented Mar 28, 2025

@swift-ci Please test Windows

@ahoppen ahoppen merged commit bfafdeb into swiftlang:main Mar 28, 2025
3 checks passed
@ahoppen ahoppen deleted the disable-sigpipe branch March 28, 2025 21:17
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

Successfully merging this pull request may close these issues.

2 participants