Skip to content

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

Open
toggysmith wants to merge 1 commit 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 1 commit 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

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)
Skip an intermittent issue tests/misc/tty-eof (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/tail/tail-n0f (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/pr/bounded-memory (passes in this run but fails in the 'main' branch)
Congrats! The gnu test tests/mktemp/write-error is no longer failing!

@codspeed-hq

codspeed-hq Bot commented Jun 22, 2026

Copy link
Copy Markdown

Merging this PR will degrade performance by 3.74%

❌ 1 regressed benchmark
✅ 322 untouched benchmarks
⏩ 46 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation sort_long_line[10000] 406.9 µs 422.7 µs -3.74%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing toggysmith:mktemp-stdout-issue (754b58b) with main (f50adad)

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

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