message: Use a finer-grained approach to setting the terminal leader
diff: @@ -133,12 +133,14 @@ fn parse_args() -> CommandLineArgs {
  fn set_unique_pid() -> nix::Result<()> {
  let pgid = unistd::getpid();
  - if pgid == unistd::tcgetpgrp(nix::libc::STDIN_FILENO)? {
  - return Ok(());
  - }
  + if pgid != unistd::getpgrp() {
  unistd::setpgid(pgid, pgid)?;
  + }
  + if pgid != unistd::tcgetpgrp(nix::libc::STDIN_FILENO)? {
  unsafe { signal::signal(Signal::SIGTTOU, SigHandler::SigIgn) }?;
  - unistd::tcsetpgrp(nix::libc::STDIN_FILENO, pgid)
  + unistd::tcsetpgrp(nix::libc::STDIN_FILENO, pgid)?;
  + }
  + Ok(())
  }
  fn main() {
  