Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

signal: terminal: Changes to support build in Darwin #87

Merged
merged 2 commits into from
Jun 22, 2018

Conversation

raravena80
Copy link
Member

@raravena80 raravena80 commented Jun 19, 2018

So, there's some code duplication between terminal_linux.go, terminal_linux_test.go and terminal_darwin.go and terminal_darwin_test.go. We can leave it as it is now, or we can refactor the code into perhaps one single terminal.go and then specific terminal_linux.go and then terminal_darwin.go. Refactoring will also require changing the test files.

Lmk

Copy link
Member

@bergwolf bergwolf left a 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.

Copy link
Contributor

@jodh-intel jodh-intel left a 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:

@@ -0,0 +1,52 @@
// +build darwin
//
// Copyright (c) 2017 Intel Corporation
Copy link
Contributor

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?

Copy link
Member Author

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.

Copy link
Contributor

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 ;-)

Copy link
Member Author

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 :)

}

func restoreTerminal(fd int, termios *unix.Termios) error {
//return unix.IoctlSetTermios(fd, unix.TCSETS, termios)
Copy link
Contributor

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,
Copy link

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.

Copy link

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 ?

Copy link
Member Author

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.

Copy link
Member Author

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.

Copy link

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.

Copy link
Contributor

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?

Copy link

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.

Copy link
Member Author

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 :)

Copy link
Contributor

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 ;)

Copy link
Member Author

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
Copy link

codecov bot commented Jun 19, 2018

Codecov Report

Merging #87 into master will increase coverage by 2.46%.
The diff coverage is 88.88%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
signals.go 64.7% <ø> (ø) ⬆️
terminal_darwin.go 88.88% <88.88%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 087a537...27339b0. Read the comment docs.

@raravena80 raravena80 force-pushed the master branch 3 times, most recently from c103180 to f149098 Compare June 20, 2018 15:58
@jodh-intel
Copy link
Contributor

jodh-intel commented Jun 20, 2018

lgtm

Approved with PullApprove

Copy link
Member

@amshinde amshinde left a comment

Choose a reason for hiding this comment

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

lgtm

@jodh-intel
Copy link
Contributor

Hi @raravena80 - Travis is failing and if you look at the log you'll see:

Found 2 commits between commit f14909849e2a66323ae617cb1af6651d12ac5520 and branch master
ERROR: Commit 095b68ab469922faa96a5a5f3cb637028e6345b6: subject too long (max 75, got 153): "signal: Removing SIGSTKFLT since it's not used in either the Linux or Darwin implementations. According to the man 7 page on Linux the signal is not used"
ERROR: checkcommits failed. See the document below for help on formatting
commits for the project.
https://github.com/kata-containers/community/blob/master/CONTRIBUTING.md#patch-format

Hence, I suggest you change your commits to something like:

signal: Removed SIGSTKFLT

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>
terminal: Add support for Darwin

Created a new `terminal_darwin.go` (and associated test).

Fixes #86

Signed-off-by: Ricardo Aravena <raravena@branch.io>

Also, please see my comment above about updating .travis.yml: #87 (review).

@jodh-intel
Copy link
Contributor

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>
@raravena80
Copy link
Member Author

@jodh-intel made the changes. Also added osx to travis.

@raravena80 raravena80 force-pushed the master branch 3 times, most recently from 6667122 to 27339b0 Compare June 21, 2018 18:30
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>
@jodh-intel
Copy link
Contributor

Thanks @raravena80!

lgtm

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants