Skip to content

fix(ui): keep suspended jobs alive upon fg - #996

Open
HackAttack wants to merge 1 commit into
modem-dev:mainfrom
HackAttack:fix/suspend
Open

fix(ui): keep suspended jobs alive upon fg#996
HackAttack wants to merge 1 commit into
modem-dev:mainfrom
HackAttack:fix/suspend

Conversation

@HackAttack

@HackAttack HackAttack commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

When backgrounding with Ctrl-Z in the shell, fg can kill the process instead of bringing it back to the foreground.

Before stopping Hunk, OpenTUI prepares the terminal for the shell: it leaves raw mode, stops reading stdin, and removes its keep-alive timer. The stopped process remains alive, but after fg wakes it, the runtime
could exit before Hunk's SIGCONT callback restarted the renderer.

The stop actually takes effect before kill returns, since POSIX delivers a signal sent to the caller's own process group before the call completes. So suspend and resume become one straight line, and staying on that call stack is what keeps the job alive: the event loop never gets a chance to go idle and exit. That retires the SIGCONT listener along with the per-suspend state tracking it needed.

It also closes a hang. The old fallback only ran when kill threw, so a SIGTSTP that was delivered and discarded — as POSIX requires for an orphaned process group — left the app suspended forever, waiting for a SIGCONT nobody would send. Both cases now reach the same restore.

@vercel

vercel Bot commented Sep 6, 2026

Copy link
Copy Markdown

@HackAttack is attempting to deploy a commit to the Modem Team on Vercel.

A member of the Team first needs to authorize it.

@greptile-apps

greptile-apps Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

PR author is not in the allowed authors list.

@HackAttack
HackAttack force-pushed the fix/suspend branch 2 times, most recently from 5f77cb4 to 6b1914c Compare September 6, 2026 01:24
When backgrounding with Ctrl-Z in the shell, fg can kill the process
instead of bringing it back to the foreground.

Before stopping Hunk, OpenTUI prepares the terminal for the shell: it
leaves raw mode, stops reading stdin, and removes its keep-alive timer.
The stopped process remains alive, but after fg wakes it, the runtime
could exit before Hunk's SIGCONT callback restarted the renderer.

The stop actually takes effect before kill returns, since POSIX delivers
a signal sent to the caller's own process group before the call
completes. So suspend and resume become one straight line, and staying
on that call stack is what keeps the job alive: the event loop never
gets a chance to go idle and exit. That retires the SIGCONT listener
along with the per-suspend state tracking it needed.

It also closes a hang. The old fallback only ran when kill threw, so a
SIGTSTP that was delivered and discarded — as POSIX requires for an
orphaned process group — left the app suspended forever, waiting for a
SIGCONT nobody would send. Both cases now reach the same restore.

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
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.

1 participant