mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Add missing file
This commit is contained in:
parent
dcf4572a69
commit
f73401fb9a
1 changed files with 27 additions and 0 deletions
27
rcli/utils.go
Normal file
27
rcli/utils.go
Normal file
|
@ -0,0 +1,27 @@
|
|||
package rcli
|
||||
|
||||
import (
|
||||
"github.com/dotcloud/docker/term"
|
||||
"os"
|
||||
"os/signal"
|
||||
)
|
||||
|
||||
//FIXME: move these function to utils.go (in rcli to avoid import loop)
|
||||
func SetRawTerminal() (*term.State, error) {
|
||||
oldState, err := term.MakeRaw(int(os.Stdin.Fd()))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
c := make(chan os.Signal, 1)
|
||||
signal.Notify(c, os.Interrupt)
|
||||
go func() {
|
||||
_ = <-c
|
||||
term.Restore(int(os.Stdin.Fd()), oldState)
|
||||
os.Exit(0)
|
||||
}()
|
||||
return oldState, err
|
||||
}
|
||||
|
||||
func RestoreTerminal(state *term.State) {
|
||||
term.Restore(int(os.Stdin.Fd()), state)
|
||||
}
|
Loading…
Reference in a new issue