Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix #4143 termios Posix library does not work on Linux#4155

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
ekrich wants to merge3 commits intoscala-native:main
base:main
Choose a base branch
Loading
fromekrich:topic/termios

Conversation

@ekrich
Copy link
Member

@ekrichekrich commentedJan 8, 2025
edited
Loading

Testing to try and fix this issue or at least try and find a path forward.

  • Add a test
  • Does it work on macOS?
  • Does it work on Linux?

Notes from Linux headers:

From/usr/include/x86_64-linux-gnu/bits/termios.h

typedefunsignedcharcc_t;typedefunsignedintspeed_t;typedefunsignedinttcflag_t;

From/usr/include/x86_64-linux-gnu/bits/termios-struct.h

#defineNCCS 32structtermios  {tcflag_tc_iflag;/* input mode flags */tcflag_tc_oflag;/* output mode flags */tcflag_tc_cflag;/* control mode flags */tcflag_tc_lflag;/* local mode flags */cc_tc_line;/* line discipline */cc_tc_cc[NCCS];/* control characters */speed_tc_ispeed;/* input speed */speed_tc_ospeed;/* output speed */#define_HAVE_STRUCT_TERMIOS_C_ISPEED 1#define_HAVE_STRUCT_TERMIOS_C_OSPEED 1  };

@ekrich
Copy link
MemberAuthor

@LeeTibbert I don't have a Linux env so I am not sure I can complete this. Any chance you could look into this?

@LeeTibbert
Copy link
Contributor

@ekrich

Be glad to, but it would have to be the beginning of next week, and not Tuesday, April 1.
I hope a few day's delay does not break your momentum.

IMO, you are entirely right, any change or code not exercised or tested is, by definition, broken.

I'm trying to get a large & complicated 'Arrays` JDK9 PR off the shipping dock.

@ekrich
Copy link
MemberAuthor

@LeeTibbert I was thinking that the smaller Linux sizes are big enough to handle 32 and 64 bit flags but wondering then what happens with struct alignment on macOS?

@LeeTibbert
Copy link
Contributor

@ekrich

Sorry this fell off the bottom of my work list.

In the interest of not holding you up, I'll give the TL;DR and then
fall back to my usual careful development of a chain of reasoning & evidence.

TL;DR

Jumping to solution, this looks like a case whereOps extension methods could
be used to hide os differences. The hard problem there is letting people know
that such exist and that they need to import not onlytermios but alsotermiosOps.

We, as in you and I, dealt with such an situation with, IIRC, BSD sin6_len & sin_len.

The critical & discriminating pieces of information are:

  1. What are the actual os sizes on (64 bit) macOS and Linux?

  2. If the Linux os structure is smaller, what happens when it is passed more bytes
    than it expects? Does it ignore those bytes? complain? halt & catch fire?

If the linux systems we have at hand ignore those bytes, then we can do a
design sketch usingOps wizardry. This is a 'reduction in strength' fix
not 'drop-in & run'.

Discussion

Punting, for now, the "how do we inform people about Ops methods & get them to use them?" concern.

  • I can, I think, write a small C program to determine the actual total size used by one each of a macOS and
    Linux system. That gives us some clues about padding.

  • I can extend the study above to execute a termios function with the sizes determined above. A 'get'
    should be easy. I need to figure out a set of attributes which do not totally hose my terminal (or run
    that program in a 'disposable' window, not my main devo window.)

  • If the probes above go the way I think/hope they do, that is Linux ignoring the space, we can start
    the tedious process of writing the Ops to deal with the various different offsets.

  • I hate to say it, but the above assumes that the sizes & offsets will stay unchanged across time,
    operating system versions, operating systems, & architectures. At a rapid run, it looks like
    some pre-condition checking "guard" code should be added to the existingtermios.c

More as it develops.

@LeeTibbert
Copy link
Contributor

FromTermiosTest
| assertTrue(true)

Neat trick to get a test to always pass, baring Exceptions. I'll have to remember that.

}
}

@Test def testSetRawMode(): Unit = if (!isWindows) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Understod: This rapid prototyping draft

At the risk of saying what you probably intended once
you got past step 1.

Down the line, probably want to fetch the attributes
just set, into a new poisoned (known pattern, such as repeated DEADBEEF )buffer & compare the two.

Of course any mismatch leaves open the question
of "is it set or get that is broken"? We all are
familiar with that one. At least the mismatch is
detected.

@LeeTibbert
Copy link
Contributor

TIL: Today I learned.

How to bookmark an Issue or PR so I can easily find items on my currentguilt TODO list.
Obvious after the fact, but a discovery for me and, I hope, solution to a long standing desire.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

1 more reviewer

@LeeTibbertLeeTibbertLeeTibbert left review comments

Reviewers whose approvals may not affect merge requirements

At least 1 approving review is required to merge this pull request.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@ekrich@LeeTibbert

[8]ページ先頭

©2009-2025 Movatter.jp