Skip to content

pkill -f command causes tool call hang in opencode TUI #25664

Closed as not planned
Closed as not planned

Description

@zenoda

Description

Summary
In opencode TUI, sending Execute:pkill -f vim 2>/dev/null; echo "killed" causes the bash tool call to hang until timeout. Replacing -f with -x or omitting the flag makes the command finish quickly. The issue occurs regardless of whether any vim process is running.

Steps to Reproduce

  1. Open opencode TUI.
  2. Send the message:
    Execute:pkill -f vim 2>/dev/null; echo "killed"
  3. Observe that the tool call hangs and does not complete until timeout.
  4. Repeat the test with:
    • Execute:pkill -x vim 2>/dev/null; echo "killed"
    • Execute:pkill vim 2>/dev/null; echo "killed"
      These complete immediately.

Actual Result

  • With pkill -f, the bash tool call stalls and eventually times out.
  • The behavior is identical whether a vim process exists or not.

Expected Result
All three variations should finish quickly, returning the output killed , without hanging.

CLI Test (for comparison)
Testing with opencode run shows different behavior:

$ opencode run 'Execute:pkill -f vim 2>/dev/null; echo "killed"'
> build · deepseek-v4-pro
[1]    25889 terminated  opencode run 'Execute:pkill -f vim 2>/dev/null; echo "killed"'

The CLI command terminates itself, while the TUI hangs.

With -x or no flag:

$ opencode run 'Execute:pkill -x vim 2>/dev/null; echo "killed"'
> build · deepseek-v4-pro
$ pkill -x vim 2>/dev/null; echo "killed"
killed

killed

Works correctly.

Additional Information

  • The issue is specific to the -f (full argument list matching) flag of pkill.
  • The hang occurs in TUI mode only; CLI via opencode run behaves differently (process terminated rather than hang).
  • Environment: opencode TUI (1.14.33), zsh as shell.

Possible Root Cause
pkill -f may be matching the opencode process itself or its child processes in the TUI context, leading to a deadlock or wait condition. The CLI test shows self‑termination, suggesting the TUI session handles process termination differently.

Plugins

none except default plugins

OpenCode version

1.14.33

Operating System

Ubuntu 24.04.4 LTS

Terminal

gnome-terminal

Activity

  1. github-actions commented on May 4, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    In your case, pkill -f likely matches the opencode process itself (as you noted in your root cause analysis), killing or signaling it in a way that leaves the stdio pipes in a broken state, causing the same hang pattern.

  2. Levosilimo commented on Jul 3, 2026

    @Levosilimo

    Opened a fix for this in #35245 against dev.

    The hang is one path: V1 waited on Node's close event, which never fires when grandchildren inherit stdio. V2 (the core bash tool) wraps the read loop in Effect.scoped and bounds it with Effect.timeoutOrElse. V1 still had the V0 raceAll/handle.kill shape.

    This PR mirrors V2 in V1. The spawner's acquireRelease finalizer sends SIGTERM on scope cleanup. When Effect.timeoutOrElse cancels, the Deferred.await is interrupted cleanly. Pipes free, error propagates, bug-shape can't occur.

    I also created a companion plugin at https://github.com/Levosilimo/opencode-shell-hang-guard that rewrites pkill -f to a basename-guarded variant. Useful until this PR ships, optional afterward.

    bun test test/tool/shell.test.ts from packages/opencode: 25 pass, 0 fail.

  3. AbdelftahZowail commented on Aug 9, 2026

    @AbdelftahZowail

    just fucking fix it already

  4. aaronrancsik commented on Sep 15, 2026

    @aaronrancsik

    this is super annoying

  5. thdxr commented on Oct 11, 2026

    @thdxr
    Member

    Thanks for the report! OpenCode 2.0 is now out and development is focused on V2, so we're closing issues filed against OpenCode 1. Please upgrade (opencode upgrade --major, details: https://anoma.ly/notes/opencode-2-0), and if this is still relevant on 2.0, reopen this issue or open a new one with your 2.0 version.

    — from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊

  6. pizzav-xyz commented on Oct 14, 2026

    @pizzav-xyz

    fucking fix it

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions