mirror of
https://github.com/creack/pty.git
synced 2026-03-31 02:27:08 +09:00
remove deprecated nomenclature
The words "master" and "slave" in this context are both harmful and, as a technical matter, confusing and misleading. It was never my intention to use those terms in this library, but they snuck in while I wasn't paying attention. This change replaces them with "pty" and "tty", respectively, to be consistent with the other files in this package and with the device names on BSD platforms. These terms are not harmful (to the best of my knowledge) and they're more specific. In editing the comment in pty_linux.go, this patch also corrects a factual error. The ioctl argument is not "zero valued", it is a nonzero pointer to the number 0.
This commit is contained in:
@@ -46,6 +46,6 @@ func ptsname(f *os.File) (string, error) {
|
||||
|
||||
func unlockpt(f *os.File) error {
|
||||
var u _C_int
|
||||
// use TIOCSPTLCK with a zero valued arg to clear the slave pty lock
|
||||
// use TIOCSPTLCK with a pointer to zero to clear the lock
|
||||
return ioctl(f.Fd(), syscall.TIOCSPTLCK, uintptr(unsafe.Pointer(&u)))
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ func open() (pty, tty *os.File, err error) {
|
||||
* from ptm(4):
|
||||
* The PTMGET command allocates a free pseudo terminal, changes its
|
||||
* ownership to the caller, revokes the access privileges for all previous
|
||||
* users, opens the file descriptors for the master and slave devices and
|
||||
* users, opens the file descriptors for the pty and tty devices and
|
||||
* returns them to the caller in struct ptmget.
|
||||
*/
|
||||
|
||||
|
||||
12
util.go
12
util.go
@@ -8,15 +8,15 @@ import (
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
// InheritSize applies the terminal size of master to slave. This should be run
|
||||
// in a signal handler for syscall.SIGWINCH to automatically resize the slave when
|
||||
// the master receives a window size change notification.
|
||||
func InheritSize(master, slave *os.File) error {
|
||||
size, err := GetsizeFull(master)
|
||||
// InheritSize applies the terminal size of pty to tty. This should be run
|
||||
// in a signal handler for syscall.SIGWINCH to automatically resize the tty when
|
||||
// the pty receives a window size change notification.
|
||||
func InheritSize(pty, tty *os.File) error {
|
||||
size, err := GetsizeFull(pty)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = Setsize(slave, size)
|
||||
err = Setsize(tty, size)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user