Skip to content

mktemp: clean up created file/dir if writing path to stdout fails#13017

Open
toggysmith wants to merge 2 commits into
uutils:mainfrom
toggysmith:mktemp-stdout-issue
Open

mktemp: clean up created file/dir if writing path to stdout fails#13017
toggysmith wants to merge 2 commits into
uutils:mainfrom
toggysmith:mktemp-stdout-issue

Conversation

@toggysmith

Copy link
Copy Markdown

Context

In the GNU version of mktemp, if the path of the created file/directory cannot be written to stdout, it will clean up by deleting the created file/directory. In the uutils version of mktemp, this does not happen and the file/directory remains. This PR rectifies this difference in behaviour.

Changes

  • Flush immediately in println_verbatim, so that any write failures also appear immediately.
  • Check for a failure - after trying to print the path - and if one occurred, delete the created file/directory.

Testing

Manual

GNU behaviour:

toggy-smith@toggysmith:/example$ mktemp XXX.txt > /dev/full
mktemp: write error: No space left on device
toggy-smith@toggysmith:/example$ ls
toggy-smith@toggysmith:/example$ 

Previous behaviour:

toggy-smith@toggysmith:/example$ mktemp XXX.txt > /dev/full
mktemp: failed to print directory name: No space left on device
Error flushing stdout: No space left on device (os error 28)
toggy-smith@toggysmith:/example$ ls
fuF.txt

New behaviour:

toggy-smith@toggysmith:/example$ mktemp XXX.txt > /dev/full
mktemp: failed to print directory name: No space left on device
Error flushing stdout: No space left on device (os error 28)
toggy-smith@toggysmith:/example$ ls
toggy-smith@toggysmith:/example$ 

GNU test suite

Before:

================================================
   GNU coreutils 9.11: ./tests/test-suite.log
================================================

# TOTAL: 1
# PASS:  0
# SKIP:  0
# XFAIL: 0
# FAIL:  1
# XPASS: 0
# ERROR: 0

[REDACTED SYSTEM INFO]

.. contents:: :depth: 2

FAIL: ../gnu/tests/mktemp/write-error
=====================================

mktemp: failed to print directory name: No space left on device
mktemp: failed to print directory name: No space left on device
FAIL ../gnu/tests/mktemp/write-error.sh (exit status: 1)

After:

================================================
   GNU coreutils 9.11: ./tests/test-suite.log
================================================

# TOTAL: 1
# PASS:  1
# SKIP:  0
# XFAIL: 0
# FAIL:  0
# XPASS: 0
# ERROR: 0

[REDACTED SYSTEM INFO]

.. contents:: :depth: 2

@github-actions

github-actions Bot commented Jun 22, 2026

Copy link
Copy Markdown

GNU testsuite comparison:

Skip an intermittent issue tests/cut/bounded-memory (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/date/date-locale-hour (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/tail/tail-n0f (passes in this run but fails in the 'main' branch)
Congrats! The gnu test tests/mktemp/write-error is no longer failing!
Note: The gnu test tests/basenc/bounded-memory is now being skipped but was previously passing.
Note: The gnu test tests/cut/cut-huge-range is now being skipped but was previously passing.

@codspeed-hq

codspeed-hq Bot commented Jun 22, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 331 untouched benchmarks
⏩ 46 skipped benchmarks1


Comparing toggysmith:mktemp-stdout-issue (cc8275d) with main (eae191c)

Open in CodSpeed

Footnotes

  1. 46 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@sylvestre

Copy link
Copy Markdown
Contributor

a bunch of jobs are failing

@toggysmith

Copy link
Copy Markdown
Author

Ah, thanks! I didn't spot that but I've fixed the Windows build issue now.

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