-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use x/term
on Unix systems, deduplicate tscreen_*.go
#2
base: legacy
Are you sure you want to change the base?
Conversation
tscreen_darwin.go
Outdated
var tios uintptr | ||
var ioc uintptr | ||
t.tiosp = &termiosPrivate{} | ||
var state *term.State | ||
|
||
if t.in, e = poller.Open("/dev/tty", poller.O_RO); e != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another file descriptor is opened upstream to fix the bug and there is no duplicate code just on MacOS, but I have not tried checking how much does the code structure need to be changed when using the same method yet.
Unfortunately I've no MacOS for tests too. |
e0961ee
to
e701458
Compare
I have split the changes into different commits since not all are similar.
Would it be possible if Zachary could test if bugs don't occur when running shell commands in Micro with this pull request, and if they do on the commit before e701458 (1482264)? I remember seeing old comments in issues where he seemed to have MacOS, but I'll re-add |
Set VMIN and VTIME to read all input before closing tty, using tcSetBufParams() added from upstream source code.
e701458
to
60065f3
Compare
Sorry, I realized that there were files I did not add so I added them now. |
Reasons why
syscall.Syscall6(syscall.SYS_IOCTL, ...)
has to be replaced are written below:Syscall(...)
and Go 1.23 or newer has to be used withSYS_IOCTL
sincesyscall(2)
is removed in OpenBSD 7.5unsafe.Pointer
has to be converted touintptr
in arguments like written in 4th pattern in documentationThere may be changes in any platform where using
syscall.Syscall*
will not work, so calls are replaced with functions inx/sys
andx/term
instead.Input is drained as an attempt to remove code that is duplicated to address bug(s) on MacOS, but I wasn't able to understand how they exactly occur. There only seemed to be one occuring when I tried searching about the explanations in source code comments.
The addressed bug probably occurs when closing
/dev/tty
since polling done internally withos.File
doesn't work on MacOS.12 I am also not sure if this workaround in upstream addresses the same bug or should be done in the fork. Code could be reduplidcated if not practical to come up with a better fix.Micro started up properly when I tested using an OpenBSD 7.6 VM. I do not have a MacOS machine so I cannot test if there are no bugs on MacOS. The changes may not be tested and thought well enough.
Fixes zyedidia/micro#3557
Footnotes
https://github.com/gokcehan/lf/issues/480#issuecomment-782896586 ↩
https://nathancraddock.com/blog/macos-dev-tty-polling/ ↩