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

[macOS] Non-canonical Mode Input Processing #151

Closed lonnywong closed 2 years ago

lonnywong commented 2 years ago

For https://github.com/creack/pty/issues/150

kr commented 2 years ago

Turning off canonical mode by default would be surprising to most clients of this package. I'd suggest finding another way to accommodate this need.

If there's already a way for clients to do this themselves, that's probably sufficient?

lonnywong commented 2 years ago

Turning off canonical mode by default would be surprising to most clients of this package. I'd suggest finding another way to accommodate this need.

Linux turns off canonical mode by default.

I think the canonical mode is not a big deal for most clients. Could you give an example relying on the canonical mode?

kr commented 2 years ago

Linux turns off canonical mode by default.

This is interesting. If there's a difference in default behavior between different platforms, arguably this package should try to smooth that over.

Or, arguably, the job of this package is to provide access to the underlying platform, and if there are differences, that's what you get.

I think the canonical mode is not a big deal for most clients. Could you give an example relying on the canonical mode?

Not without doing some research, I cant! I was making an assumption.

However, I think the burden of proof is in the other direction. If you're proposing a change to the current behavior, you should show evidence that existing clients won't break. (Or, you can show that the benefit of the change outweighs the cost of breakage. But that still requires estimating the cost of breakage so it can be weighed against the benefit.)

lonnywong commented 2 years ago

@kr I'm not asking for evidence. I'm asking for help. I'm not sure what kind of clients will depend on it, just trying to understand what they needs.

lonnywong commented 2 years ago

Sorry, I made a mistake. By default, ICANON is set on Linux. The maximum line length is 4096 chars on Linux, while it is 1024 on macOS.

Actually, my program works fine on both Linux and macOS. I don't know why I can read a line over 4096 chars with trzsz, but I can't with the test case https://github.com/creack/pty/issues/150.

But, my program fails on Windows with ConPTY. Still don't know why.

kr commented 2 years ago

@kr I'm not asking for evidence. I'm asking for help. I'm not sure what kind of clients will depend on it, just trying to understand what they needs.

Sorry I misunderstood!

I'm glad you've made progress on the problem.

lonnywong commented 2 years ago

Thanks. I figured out why the windows ConPTY is not working too. But there is no API to disable ENABLE_LINE_INPUT with ConPTY for now. Have to disable ENABLE_LINE_INPUT in the child process, which I can't control.