Skip to content

Fix "Restarting" screen stuck forever#337

Merged
3rdIteration merged 5 commits intodevfrom
copilot/fix-restarting-screen-issue
Mar 17, 2026
Merged

Fix "Restarting" screen stuck forever#337
3rdIteration merged 5 commits intodevfrom
copilot/fix-restarting-screen-issue

Conversation

Copy link

Copilot AI commented Mar 13, 2026

Description

The restart screen hangs indefinitely because pidof python* doesn't work — pidof doesn't support shell globs. The wildcard expands against the current directory (matching nothing), so kill receives no PID and the process is never terminated.

Fix: Replace unreliable pidof/ps+grep process lookup with os.getpid() and sys.executable:

# Before (broken — pidof doesn't support wildcards)
call("kill $(pidof python*) & python /opt/src/main.py", shell=True)

# After
pid = os.getpid()
python = shlex.quote(sys.executable)
call(f"kill {pid}; exec {python} /opt/src/main.py", shell=True)

Additional changes:

  • Thread safety for tests: DoResetThread checks self.keep_running before executing kill. RestartView.run() stops the thread on exception. This prevents the now-functional kill from terminating the screenshot generator process (which exercises RestartView without mocking the thread).
  • Shell hardening: shlex.quote() on sys.executable; &; so kill completes before exec.

No screenshot changes — ResetScreen UI is unchanged; only the background thread logic is fixed.

This pull request is categorized as a:

  • New feature
  • Bug fix
  • Code refactor
  • Documentation
  • Other

Checklist

  • I've run pytest and made sure all unit tests pass before sumbitting the PR

If you modified or added functionality/workflow, did you add new unit tests?

  • No, I'm a fool
  • Yes
  • N/A

I have tested this PR on the following platforms/os:


📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.

Copilot AI and others added 2 commits March 13, 2026 21:42
…dcard

The "Restarting" screen would stay on forever because `pidof python*`
does not work — pidof does not support shell glob wildcards. The shell
expands `python*` as a file glob (matching nothing), so pidof receives
a literal `python*` which it cannot resolve. As a result, `kill` gets
no PID arguments and the process is never terminated.

Fix: Use `os.getpid()` for a reliable PID and `sys.executable` for the
correct Python binary path, eliminating the dependency on pidof and
hardcoded binary names.

Co-authored-by: 3rdIteration <2230318+3rdIteration@users.noreply.github.com>
Addresses code review feedback: shell-escape the Python executable path
to prevent issues if the path contains spaces or special characters.

Co-authored-by: 3rdIteration <2230318+3rdIteration@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix issue with restarting screen not functioning Fix "Restarting" screen stuck forever: pidof doesn't support wildcards Mar 13, 2026
Copilot AI requested a review from 3rdIteration March 13, 2026 21:45
Copilot AI and others added 2 commits March 14, 2026 14:45
… test

The screenshot generator exercises RestartView without mocking the
DoResetThread. Now that the kill command actually works (os.getpid()),
the thread was killing the test process.

Fix: RestartView.run() wraps run_screen() in try/except to call
thread.stop() on any exception (like ScreenshotComplete). DoResetThread
checks keep_running before executing the kill, so stopped threads
exit gracefully without killing the process.

Co-authored-by: 3rdIteration <2230318+3rdIteration@users.noreply.github.com>
…est race

- Add explanatory comment for the broad Exception catch in RestartView
- Move shlex import to file-level in test_flows_view.py
- Set keep_running directly instead of start()/stop() to avoid race

Co-authored-by: 3rdIteration <2230318+3rdIteration@users.noreply.github.com>
Copilot AI changed the title Fix "Restarting" screen stuck forever: pidof doesn't support wildcards Fix "Restarting" screen stuck forever Mar 14, 2026
@3rdIteration 3rdIteration marked this pull request as ready for review March 17, 2026 03:02
Copilot AI review requested due to automatic review settings March 17, 2026 03:02
@3rdIteration 3rdIteration merged commit 832d8d7 into dev Mar 17, 2026
9 checks passed
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes SeedSigner’s “Restarting” screen hanging indefinitely by replacing unreliable process lookup (pidof python* / ps|grep) with a deterministic restart strategy based on the current PID and Python executable.

Changes:

  • Restart now uses os.getpid() to reliably target the current process, and sys.executable (quoted) to restart on seedsigner-os.
  • Added a safety stop-path: if ResetScreen exits via exception, the reset thread is stopped to avoid killing the running process during screenshot/test scenarios.
  • Added unit tests validating the exact subprocess command constructed in each environment branch and verifying the “stopped thread” no-op behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/seedsigner/views/view.py Updates RestartView reset-thread behavior to kill by PID and restart using sys.executable, plus stops the thread on abnormal screen exit.
tests/test_flows_view.py Adds tests that assert the constructed reset commands for seedsigner-os vs desktop and ensure the thread skips the kill when stopped.

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.

3 participants