Skip to content

Handle denied process exe lookup in rerun#1600

Open
puneetdixit200 wants to merge 1 commit into
nvbn:masterfrom
puneetdixit200:fix-rerun-access-denied-exe
Open

Handle denied process exe lookup in rerun#1600
puneetdixit200 wants to merge 1 commit into
nvbn:masterfrom
puneetdixit200:fix-rerun-access-denied-exe

Conversation

@puneetdixit200

Copy link
Copy Markdown

Fixes #1158.

When a rerun times out and The Fuck cannot terminate a process due to psutil.AccessDenied, _kill_process logs the process executable. On sudo-owned processes, that executable lookup can also raise AccessDenied, which turns the timeout handling path into a traceback.

This keeps the timeout cleanup best-effort by falling back to a placeholder executable name when proc.exe() is denied, so the rerun path can return normally instead of crashing.

Verification:

  • PYTHONPATH=. .venv/bin/python -m pytest tests/output_readers/test_rerun.py::TestRerun::test_kill_process_access_denied_when_exe_is_denied -q
  • PYTHONPATH=. .venv/bin/python -m pytest tests/output_readers/test_rerun.py -q
  • PYTHONPATH=. .venv/bin/python -m pytest tests/rules/test_apt_list_upgradable.py tests/rules/test_apt_upgrade.py -q
  • PYTHONPATH=. .venv/bin/python -m pytest tests/output_readers -q
  • .venv/bin/python -m py_compile thefuck/output_readers/rerun.py tests/output_readers/test_rerun.py
  • .venv/bin/python -m flake8 thefuck/output_readers/rerun.py tests/output_readers/test_rerun.py
  • git diff --check

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.

running fuck after successful apt update errors after several seconds

1 participant