Skip to content

exec: fix pgrp handoff and raw mode propagation - #593

Open
realvolk wants to merge 1 commit into
sudo-project:mainfrom
realvolk:fix-pty-pgrp
Open

realvolk wants to merge 1 commit into
sudo-project:mainfrom
realvolk:fix-pty-pgrp

Conversation

@realvolk

@realvolk realvolk commented Nov 5, 2026

Copy link
Copy Markdown

Fixes:

  1. use_pty with non-tty stdin: command starts in background pgrp; foreground handoff only reaches the original pgrp, so a shell that creates its own pgrp (zsh) ends up unusable on FreeBSD/macOS #583: In exec_monitor.c, replaced tcgetpgrp() with getpgid(mc->cmnd_pid) in mon_handle_sigchld. tcgetpgrp() returns the orphaned pgrp when the child sets a new one and stops on SIGTTIN.
  2. Background sudo leaves terminal settings in raw-ish state after suspend/resume #552: In exec_pty.c, made pty_cleanup unconditionally call sudo_term_restore if SFD_USERTTY is valid. Fixes a race where the tty was left in raw mode if the process wasn't in the foreground.
  3. pv does not work with sudo unless use_pty is disabled #553: In exec_pty.c, use term_raw_flags for the user tty. Cleared OPOST manually on the pty leader so \r works, avoiding clobbering the saved user tty state.

Tested on Linux (Artix, x86_64) with zsh, pv, and background/foreground transitions. Needs BSD/macOS testing for #583.

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