-
Notifications
You must be signed in to change notification settings - Fork 48
signal: terminal: Changes to support build in Darwin #87
Conversation
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.
This is pretty close to terminal_linux.go, maybe we can have a common terminal.go that builds on both Linux and Darwin?
That said, the code is small enough to be kept both and we likely do not need to update it anyway. So I'm giving my LGTM.
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.
Hi @raravena80 - thanks for raising!
I like the idea of having a Darwin implementation.
A couple of things:
-
Please can you update
.travis.yml
so that we test on Linux andosx
: https://docs.travis-ci.com/user/customizing-the-build#Mac-OS.
But also keep in mind: Remove TravisCI kata-containers#22. -
If you haven't already seen it, you probably need to be aware of: Reduce footprint by implementing shim with other language #83.
terminal_darwin.go
Outdated
@@ -0,0 +1,52 @@ | |||
// +build darwin | |||
// | |||
// Copyright (c) 2017 Intel Corporation |
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.
I see that this is based on terminal_linux.go
but I think you need to add an additional 2018 copyright with your name against it. Is that correct @grahamwhaley?
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.
I'll change it to 2017-2018 pending @grahamwhaley's comment.
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.
correct - you may optionally want to add your own copyright line @raravena80 . But, don't update the Intel line to 2017-2018, if an Intel person didn't touch it ;-)
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.
ok cool, I just left it like it was :)
terminal_darwin.go
Outdated
} | ||
|
||
func restoreTerminal(fd int, termios *unix.Termios) error { | ||
//return unix.IoctlSetTermios(fd, unix.TCSETS, termios) |
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.
Can you remove this commented-out code please.
syscall.SIGILL: true, | ||
syscall.SIGQUIT: true, | ||
syscall.SIGSEGV: true, | ||
syscall.SIGSTKFLT: true, |
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.
@raravena80 could you please add a commit message explaining a bit what this patch is doing, and particularly the removal of SIGSTKFLT
.
Maybe splitting this into two commits might help clarifying that too.
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.
BTW, are you planning to implement what you mentioned in the issue? I mean having this signals.go
as a common part between different OSes, and define signals_linux.go
and signals_darwin.go
for specific ones ?
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.
@sboeuf looking for feedback. I'm fine the way it is, but looking to get the team's take on it.
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.
Added the commit message with explanations for both signal and terminal. Let me know, I can also split these in two.
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.
I think the simplest way would be to have signals_linux.go
and signals_darwin.go
with the build flag linux
and darwin
respectively. This way it is pretty clear what is being used depending on the OS, and I don't think the duplication is a problem here.
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.
if you have the file name extentions (_$GOARCH), then you don't need the in-file tags, do you?
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.
Oh interesting, looking here: https://golang.org/pkg/go/build/, you're right. But it cannot hurt to put the build flag on top of each file, just as an enforcement action.
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.
Right, you don't need it but like @sboeuf mentioned it may be good to keep for informational purposes :)
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.
Regarding build flag vs. filename, I'm not sure which one "trumps" the other. I'd rather we just use the filename as that's the convention we're using and we don't want to have to maintain two things for the same purpose ;)
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.
sounds good. I just removed the +build
header.
Codecov Report
@@ Coverage Diff @@
## master #87 +/- ##
==========================================
+ Coverage 50.96% 53.42% +2.46%
==========================================
Files 6 7 +1
Lines 259 277 +18
==========================================
+ Hits 132 148 +16
- Misses 115 116 +1
- Partials 12 13 +1
Continue to review full report at Codecov.
|
c103180
to
f149098
Compare
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.
lgtm
Hi @raravena80 - Travis is failing and if you look at the log you'll see:
Hence, I suggest you change your commits to something like:
Also, please see my comment above about updating |
In summary, we like the first commit line (the summary) to have a "subsystem" prefix and a very short description. After a blank line, knock yourself out with full details! ;) |
According to the man 7 page on Linux the signal is not used. Further, it is not defined on Darwin. Signed-off-by: Ricardo Aravena <raravena@branch.io>
@jodh-intel made the changes. Also added osx to travis. |
6667122
to
27339b0
Compare
Created a new `terminal_darwin.go` (and associated test). Made changes to .travis.yml and .ci/faketty.sh to support travis osx tests Fixes kata-containers#86 Signed-off-by: Ricardo Aravena <raravena@branch.io>
Thanks @raravena80! lgtm |
So, there's some code duplication between
terminal_linux.go
,terminal_linux_test.go
andterminal_darwin.go
andterminal_darwin_test.go
. We can leave it as it is now, or we can refactor the code into perhaps one singleterminal.go
and then specificterminal_linux.go
and thenterminal_darwin.go
. Refactoring will also require changing the test files.Lmk