Skip to content

Detach stdin when running badfiles checker commands#6797

Open
augboz wants to merge 2 commits into
beetbox:masterfrom
augboz:fix/badfiles-detach-stdin
Open

Detach stdin when running badfiles checker commands#6797
augboz wants to merge 2 commits into
beetbox:masterfrom
augboz:fix/badfiles-detach-stdin

Conversation

@augboz

@augboz augboz commented Jun 28, 2026

Copy link
Copy Markdown

Closes #6750.

The badfiles checker commands (mp3val, flac, custom) are non-interactive, but run_command launched them with the parent's stdin still attached to the controlling terminal. A checker can leave the TTY in a modified state (e.g. echo disabled), so after beet bad the terminal stops echoing typed input until reset/stty sane.

Fix: pass stdin=DEVNULL to check_output so checkers can't read from or modify the terminal.

Note on verification: the symptom is terminal-state-specific and I couldn't reproduce it on my (Windows) machine, but the root cause is clear from the code path. I've added a regression test asserting run_command calls check_output with stdin=DEVNULL, and a changelog entry.

The `badfiles` checker commands (mp3val, flac, custom) are non-interactive,
but were launched with the parent process's stdin still attached to the
controlling terminal. A checker could leave the TTY in a modified state
(e.g. with input echo disabled), so after `beet bad` the terminal stopped
echoing typed input until `reset` or `stty sane` was run.

Pass `stdin=DEVNULL` to `check_output` so the checkers cannot read from or
modify the terminal. Adds a regression test asserting `run_command`
detaches stdin, plus a changelog entry.

Closes beetbox#6750
@augboz augboz requested a review from a team as a code owner June 28, 2026 14:30
@github-actions github-actions Bot added the badfiles badfiles plugin label Jun 28, 2026
@codecov

codecov Bot commented Jun 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.87%. Comparing base (37e2a8b) to head (2c011fe).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6797      +/-   ##
==========================================
+ Coverage   74.85%   74.87%   +0.02%     
==========================================
  Files         163      163              
  Lines       20947    20947              
  Branches     3299     3299              
==========================================
+ Hits        15680    15685       +5     
+ Misses       4510     4504       -6     
- Partials      757      758       +1     
Files with missing lines Coverage Δ
beetsplug/badfiles.py 33.95% <100.00%> (+4.32%) ⬆️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

badfiles badfiles plugin

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unable to see terminal input after beet bad

1 participant