Skip to content

Commit

Permalink
Add missing file
Browse files Browse the repository at this point in the history
  • Loading branch information
creack authored and Louis Opter committed Apr 8, 2013
1 parent dcf4572 commit f73401f
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions rcli/utils.go
Original file line number Diff line number Diff line change
@@ -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)
}

0 comments on commit f73401f

Please sign in to comment.