Skip to content

[bug] Background job with redirect runs under --internal-bg-wrapper: signals never reach job traps #1033

Closed

Description

@caomengxuan666

[bug] Background job WITH redirect runs under --internal-bg-wrapper: signals never reach the job's traps (HIGH)

# c.sh:
trap 'echo GOTTERM; exit 42' TERM
echo READY
sleep 30 &
wait $!
# driver (parent shell): <parent> c.sh >o.txt 2>&1 & P=$!; wait READY; kill -TERM $P; wait $P
# bash parent:  bg pid is the real job; GOTTERM printed; wait rc=42
# niu parent:   bg pid is `niu --internal-bg-wrapper=...`; NO GOTTERM; wait rc=143

Any redirect on the bg job (>o.txt, also 2>&1) triggers the wrapper; bare sleep 30 & runs direct and reaps clean. kill/wait act on the wrapper, the TERM never reaches the real job's trap. Observed fallout: orphaned sleep 30 with PPID=1 surviving minutes after the parent died (leaked processes).

Env: niubash 1.4.4 / rubash engine (master ~2026-10), GNU bash 5.3.20 aarch64-linux-android as oracle.

Activity

  1. github-actions commented on Oct 22, 2026

    @github-actions
    Contributor

    欢迎!这是你在本仓库的第一个 ISSUE 🎉 维护者会尽快跟进;报 bug 请附 rubash --version、系统平台与最小复现脚本。

  2. added
    bug
    gnu-baseline
    area:jobs
    family:S9
    P1-high
    on Oct 22, 2026
  3. caomengxuan666 commented on Oct 23, 2026

    @caomengxuan666
    MemberAuthor

    Verified fixed on master (a55e4d6) — fixed by 55cc97f 'fix(jobs): redirected simple background externals spawn directly, not via the -c wrapper (#1033)'.

    Driver repro against release build of current master (rubash c.sh >o.txt 2>&1 & P=$!; kill -TERM $P; wait $P where c.sh traps TERM → 'echo GOTTERM; exit 42'):

    wait-rc=42
    READY
    GOTTERM
    

    Matches GNU bash 5.3.20 exactly: the bg pid is the real job, TERM reaches the trap, wait returns 42. No orphaned sleep observed (checked tasklist after the run).

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1-higharea:jobsbugfamily:S9gnu-baseline

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions