Skip to content

[pkg/term] refactor and switch syscall to x/sys#33180

Merged
tiborvass merged 3 commits intomoby:masterfrom
tophj-ibm:switch-pkg-term-syscalls-to-x/sys
May 17, 2017
Merged

[pkg/term] refactor and switch syscall to x/sys#33180
tiborvass merged 3 commits intomoby:masterfrom
tophj-ibm:switch-pkg-term-syscalls-to-x/sys

Conversation

@tophj-ibm
Copy link
Contributor

Part of a bigger plan to switch all syscall references to x/sys, but I thought
I would start small.

Switches calls to syscall to x/sys, which is more up to date.
This is fixes a number of possible bugs on other architectures
where ioctl tcget and tcset aren't implemented correctly.

There are a few remaining syscall references, because x/sys doesn't
have an Errno, Signal, or SysProcAttr implementation yet.

Also removes a ppc64le and cgo build tag that fixes building on
ppc64le without cgo which was a problem because we weren't using
/x/sys

Signed-off-by: Christopher Jones [email protected]

@tophj-ibm
Copy link
Contributor Author

cc @clnperez @tiborvass @cpuguy83

@unclejack
Copy link
Contributor

@tophj-ibm There seem to be two issues with the code:

19:09:26 pkg/term/term.go:14: imported and not used: "github.com/docker/docker/vendor/golang.org/x/sys/unix"
19:09:26 pkg/term/term.go:83: undefined: syscall in syscall.ECHO

@tophj-ibm tophj-ibm force-pushed the switch-pkg-term-syscalls-to-x/sys branch from b05148b to 60741c7 Compare May 12, 2017 20:00
@tophj-ibm
Copy link
Contributor Author

@unclejack thanks, fixed. 😓 (I swear I tested this). Windows failure is real.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

windows failure is because this and the import above it both resolve to package windows.

@jhowardmsft, because I want to make the change from syscall to -> golang.org/x/sys/(windows|unix etc) across the entire project, you have any objections to me changing the /pkg/term/windows package to something else (package windowsconsole or something)?

Copy link
Member

Choose a reason for hiding this comment

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

Go for it.

@AkihiroSuda AkihiroSuda added the status/failing-ci Indicates that the PR in its current state fails the test suite label May 13, 2017
@tophj-ibm tophj-ibm force-pushed the switch-pkg-term-syscalls-to-x/sys branch from 60741c7 to a3ebc52 Compare May 15, 2017 12:23
@tophj-ibm tophj-ibm force-pushed the switch-pkg-term-syscalls-to-x/sys branch from a3ebc52 to 7241291 Compare May 15, 2017 17:30
@dnephin dnephin removed the status/failing-ci Indicates that the PR in its current state fails the test suite label May 15, 2017
Copy link
Member

@dnephin dnephin left a comment

Choose a reason for hiding this comment

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

LGTM

@thaJeztah
Copy link
Member

@unclejack PTAL ❤️

@tiborvass
Copy link
Contributor

I was hoping that with this change we could get rid of all the cgo in pkg/term.

Switches calls to syscall to x/sys, which is more up to date.
This is fixes a number of possible bugs on other architectures
where ioctl tcget and tcset aren't implemented correctly.

There are a few remaining syscall references, because x/sys doesn't
have an Errno implementation yet.

Also removes a ppc64le and cgo build tag that fixes building on
ppc64le without cgo

Signed-off-by: Christopher Jones <[email protected]>
@tophj-ibm tophj-ibm force-pushed the switch-pkg-term-syscalls-to-x/sys branch from 7241291 to f30b072 Compare May 15, 2017 22:35
@@ -1,21 +1,21 @@
// +build !windows
// +build !linux !cgo
// +build !linux !ppc64le
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tiborvass @clnperez I think 🤞 these are right but would appreciate the double check. We still need this file because tc_solaris defines tcget/sets, but it should include the linux, cgo case.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think your "because" is throwing me. I think we still need this to catch "other" (FreeBSD & OpenBSD?).

Copy link
Contributor

Choose a reason for hiding this comment

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

Or is this also defining tcgets/tcsets for linux as well now? I think it is -- so maybe we should rename the file to tc.go ? headache

Copy link
Contributor Author

Choose a reason for hiding this comment

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

1.) This should still catch those, because they are !(windows) and (!solaris or !cgo).

2.) Sort of, it's defining a func named tcget / tcsets as the unix syscall tcget/tcset, where before it was defining them as the C ones. I think it should stay as other because it's building either the solaris file or this (other) one. If it was named tc.go and tc_solaris.go I don't think that would be as obvious, and the build constraints in these files are already confusing enough.

@tophj-ibm tophj-ibm changed the title [pkg/term] switch syscall to x/sys [pkg/term] refactor and switch syscall to x/sys May 16, 2017
@tophj-ibm
Copy link
Contributor Author

tophj-ibm commented May 16, 2017

So this PR turned into more of a refactoring of /pkg/term, so here are the total changes at this point:

1.) switch all syscall references (except for Errno because it hasn't been brought over yet) to golang.org/x/sys/(unix|windows)

2.) refactor all termios_(freebsd|darwin|openbsd) to termios_bsd (thanks @tiborvass!)

3.) remove tc_linux_cgo because it was only used as a workaround for a bug fixed by step 1.)

4.) rename tc_other.go to tc.go and change buildtags so it builds on linux/ppc64le and linux/cgo (although it doesn't use cgo)

5.) rename term_(solaris|unix) to winsize_(solaris|unix) because they were confusing with term_windows.go and term.go which are completely different files.

6.) add a cgo buildtag to now named winsize_solaris_cgo because it should have had one in the first place.

7.) rename the term/windows package to windowsconsole because it conflicts with /x/sys/windows

It should be ready for review again,
PTAL @tiborvass @dnephin @unclejack

Copy link
Member

@dnephin dnephin left a comment

Choose a reason for hiding this comment

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

LGTM

Tested with docker/cli and it fixes ppc64le

@thaJeztah
Copy link
Member

ping @jhowardmsft @tiborvass PTAL

Copy link
Member

@lowenna lowenna left a comment

Choose a reason for hiding this comment

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

Windows changes LGTM. @johnstep PTAL too

@tiborvass
Copy link
Contributor

LGTM

@tiborvass tiborvass merged commit 6f6ee6f into moby:master May 17, 2017
@GordonTheTurtle GordonTheTurtle added this to the 17.06.0 milestone May 17, 2017
@tophj-ibm tophj-ibm deleted the switch-pkg-term-syscalls-to-x/sys branch May 17, 2017 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants