Skip to content

fix: add terminal/session symbols to GOT patching for bash job control#47

Merged
Bahtya merged 2 commits into
mainfrom
fix/issue-bash-tcsetpgrp-got-patch
May 26, 2026
Merged

fix: add terminal/session symbols to GOT patching for bash job control#47
Bahtya merged 2 commits into
mainfrom
fix/issue-bash-tcsetpgrp-got-patch

Conversation

@Bahtya
Copy link
Copy Markdown
Owner

@Bahtya Bahtya commented May 26, 2026

Summary

  • Root cause: tcsetpgrp, tcgetpgrp, setsid, getpgrp, pipe2 were missing from the GOT patching list in patch_got_for_loaded_binary. When bash is loaded via dlopen, these calls bypassed vproc interceptors and hit real libc, causing EBADF on virtual fds.
  • Fix: Add the 5 missing symbols to the GOT patching match list (src/vexec.rs). The interceptors already exist in preload.rs — this just ensures they are routed correctly.
  • Effect: Eliminates bash: cannot set terminal process group (NNN): Bad file descriptor and bash: no job control in this shell warnings.

Test plan

  • Run bash inside vproc — no "cannot set terminal process group" error
  • sleep 100 & followed by fg works correctly
  • Ctrl+Z suspends foreground jobs
  • Existing test suite passes (cargo test)

Bahtya

Bahtya added 2 commits May 26, 2026 15:57
Each TerminalSession now creates its own vproc session instead of
sharing a global one. This enables true concurrency between sessions:
- Each session has its own driver thread
- run_until_exit in one session no longer blocks create_process in another
- Fixed ANR issue in Hermux when creating new terminals

Changes:
- JNI bridge: removed global g_vproc_session_id, added session array
- createSubprocess: creates new vproc session per call
- waitFor: uses session_id to call run_until_exit
- Added testConcurrentSessions and testRunUntilExitDoesNotBlockCreate

Bahtya
bash reports "cannot set terminal process group: Bad file descriptor"
because dup2(2,255) creates only a virtual fd, and the real tcsetpgrp
falls through to libc which sees no kernel fd 255 → EBADF. Adding these
symbols to the GOT patch list routes them to the existing interceptors.

Bahtya
@Bahtya Bahtya merged commit f2de177 into main May 26, 2026
@Bahtya Bahtya deleted the fix/issue-bash-tcsetpgrp-got-patch branch May 26, 2026 17:40
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