fix(mktemp): remove temporary file or directory when name cannot be printed#12889
Open
WaiHlyanMinThein17 wants to merge 2 commits into
Open
fix(mktemp): remove temporary file or directory when name cannot be printed#12889WaiHlyanMinThein17 wants to merge 2 commits into
WaiHlyanMinThein17 wants to merge 2 commits into
Conversation
…rinted When mktemp fails to write the created file or directory name to stdout (for example when stdout is /dev/full), it left the created entry behind as an orphan the caller can never reference. GNU mktemp removes it. Capture the created path and, on a print failure, remove the file or directory before propagating the error. The tempfile builder's automatic cleanup was disabled via keep(), so removal is done manually. Add a Linux-only integration test that directs stdout to /dev/full and verifies the created entry is cleaned up. Fixes the GNU test tests/mktemp/write-error.sh.
|
GNU testsuite comparison: |
Author
|
Pushed a follow-up that applies nightly rustfmt import ordering. The earlier |
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.
When
mktempcreates a temp file/directory but then fails to print itsname to stdout (e.g. stdout is
/dev/full), it left the created entrybehind as an unreachable orphan. GNU
mktempremoves it.Fix: on a print failure, remove the created file or directory before
propagating the error. Best-effort, skipped in dry-run mode.
keep()disables tempfile's auto-cleanup, so removal is manual.
Fixes the GNU test
tests/mktemp/write-error.sh. Added a Linux-onlyintegration test (file and
-dcases via/dev/full); verified it failswithout the change and passes with it.
Note: distinct from #10494, which targets shared stdout-error detection.
This is the mktemp-local cleanup the GNU test requires, and is independent.