creack / pty

PTY interface for Go
https://pkg.go.dev/github.com/creack/pty?tab=doc
MIT License
1.68k stars 234 forks source link

Does it mess my terminal settings when resizing via this library ? #170

Closed cp-endor closed 12 months ago

cp-endor commented 1 year ago

I wanted to understand if pty restores the ioctl settings once my code session is done and if it won't mess up with my local machine's OS settings.

is my assumption right as it creates a pseudo-terminal and should be fine, right?

creack commented 12 months ago

ioctl settings are distinct from the pseudo-terminal. It is the responsibility of the parent process to set / restore them.

See the example in the readme to see how to set / reset the raw mode. You can use the same approach if you need specific ioctls.

Resizing though is more about the ioctl of the child process. Again, you can check the readme for an example how to handle this. When resizing the PTY, it has no effect on the parent process nor your local machine settings.

If you set ioctl settings like raw mode on your local terminal (usually the case for shells / editors / etc), then if you don't restore them, your terminal will be broken (until you call "reset").

Closing for now, feel free to reopen if you have more concerns.