Skip to content

fix: route diagnostic output to logcat, fix tcsetpgrp for Real fds#41

Merged
Bahtya merged 3 commits into
mainfrom
fix/issue-40-logcat-tcsetpgrp
May 25, 2026
Merged

fix: route diagnostic output to logcat, fix tcsetpgrp for Real fds#41
Bahtya merged 3 commits into
mainfrom
fix/issue-40-logcat-tcsetpgrp

Conversation

@Bahtya
Copy link
Copy Markdown
Owner

@Bahtya Bahtya commented May 25, 2026

Summary

  • Closes Self-test diagnostic output leaks to terminal stdout/stderr #40
  • Add src/log.rs — lightweight logcat logging via runtime-resolved __android_log_print (zero new crate dependencies)
  • Replace all 9 libc::write(2, ...) / eprintln! diagnostic calls with vlog! / vlog_error! macros that write to Android logcat instead of terminal stdout/stderr
  • Update vdiag! macro to route through logcat as well
  • Fix tcsetpgrp / tcgetpgrp fd table check: !matches!(Vfd::Real(_)).is_some() so PTY slave fds (stored as Vfd::Real) also return fake success, eliminating bash "cannot set terminal process group" warning

Test plan

  • Cross-compile with cargo build --target aarch64-linux-android
  • Load libvproc.so in Hermux, run ls — "vproc: self-test skipped" should NOT appear in terminal
  • adb logcat -s vproc — diagnostic messages should appear in logcat
  • Start bash in a vproc session — "cannot set terminal process group" warning should be gone
  • Crash with SIGSEGV — backtrace should still print to stderr (signal-safe path unchanged)

Bahtya

Bahtya added 3 commits May 25, 2026 13:12
Add log module with vlog!/vlog_error! macros that resolve __android_log_print
via dlsym at runtime. Replace all libc::write(2,...) and eprintln! calls with
logcat logging. Only signal-safe crash handler writes remain on fd 2.

Fix tcsetpgrp/tcgetpgrp fd table check: change !matches!(Vfd::Real(_)) to
.is_some() so Real terminal fds (PTY slave) also get fake success, eliminating
bash "cannot set terminal process group" warnings.

Bahtya
…t, NUL handling

- Replace variadic fn(...) with concrete 3-arg signature (stable Rust compatible)
- Rename _Level → Level, _emit → emit (underscore prefix misleading for public API)
- Use LOG_DEBUG/LOG_ERROR constants in match instead of magic numbers
- Handle embedded NUL in CString::new with lossy fallback instead of silent drop

Bahtya
@Bahtya Bahtya merged commit 486adf5 into main May 25, 2026
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.

Self-test diagnostic output leaks to terminal stdout/stderr

1 participant