ish-app / ish

Linux shell for iOS
https://ish.app
Other
16.34k stars 856 forks source link

fix tiocgpgrp for pty master #2263

Closed ShoichiroKitano closed 7 months ago

ShoichiroKitano commented 8 months ago

I have made modifications to TIOCGPGRP for the pty master.

Currently, if the tty of the master is not set as the controlling terminal for the process group to which the current process belongs, it results in an error. However, the actual behavior in Linux is that when a file descriptor of the pty master is specified, it sets the process group ID of the controlling terminal to the corresponding slave when available. Therefore, for the pty master, I have made the modification to return the fg_group of the tty set as 'other.'

Furthermore, I have corrected the name from TIOCGPRGP, which seems to be a typo, to TIOCGPGRP.

tbodt commented 7 months ago

Thanks. Do you know if TIOCSPGRP also needs to pass through to the slave pty from the master?

If so, it'd be useful to factor out this new code to get the other side so it could be used by the other ioctls.

ShoichiroKitano commented 7 months ago

@tbodt Thank you for your comments.

I have verified that in the case of a pty master, TIOCSPGRP also needs to set the process group ID for the slave side.

Are you suggesting creating a function like the following?

static struct *tty get_slave_side_tty(struct *tty tty) {
  if (tty->type == TTY_PSEUDO_MASTER_MAJOR) {
      return tty->pty.other;
  } else {
      return tty;
  }
}
tbodt commented 7 months ago

Yes, exactly

ShoichiroKitano commented 7 months ago

@tbodt I have made the corrections.

tbodt commented 7 months ago

Thanks!