From 8de835d70856b153308b266abc7f6088826012b7 Mon Sep 17 00:00:00 2001 From: Sean Hinchee Date: Wed, 26 Jul 2017 18:56:22 +0000 Subject: [PATCH] fix raw --- config.go | 4 ++-- helper.go | 23 +++++++++++------------ 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/config.go b/config.go index c0a4411be27b47a9a467a7990125a5d8f9aa1895..442440f96b573878b8b3ddfdfea84aa91f1b50ba 100644 --- a/config.go +++ b/config.go @@ -68,7 +68,7 @@ func CreateConfig() { plan9 := true /* Plan 9 raw mode for rio */ - err = Rawon() + consctl, err := Rawon() if err != nil { fmt.Println("Failed to set rawon") plan9 = false @@ -85,7 +85,7 @@ func CreateConfig() { consScan.Scan() password = consScan.Text() - err = RawOff() + err = RawOff(consctl) if err != nil { fmt.Println("\nFailed to set rawoff") fmt.Print(err, "\n") diff --git a/helper.go b/helper.go index f4e0f707a98981bd751a28b1435a034e58add47c..d680f22e66e8f52473c2e38fe7ee22f8056fc815 100644 --- a/helper.go +++ b/helper.go @@ -96,34 +96,33 @@ func dis(a, b int) float64 { return float64((a - b) * (a - b)) } -func Rawon() error { +func Rawon() (*os.File, error){ consctl, err := os.OpenFile("/dev/consctl", os.O_WRONLY, 0200) if err != nil { /* not on Plan 9 */ fmt.Println("\nNot running on Plan 9") - return err + return consctl, err } rawon := []byte("rawon") _, err = consctl.Write(rawon) if err != nil { consctl.Close() - return err + return consctl, err } - consctl.Close() - return nil + return consctl, nil } -func RawOff() error { - consctl, err := os.OpenFile("/dev/consctl", os.O_WRONLY, 0200) - if err != nil { - /* not on Plan 9 */ - return err - } +func RawOff(consctl *os.File) error { + //consctl, err := os.OpenFile("/dev/consctl", os.O_WRONLY, 0200) + //if err != nil { + // /* not on Plan 9 */ + // return err + //} rawoff := []byte("rawoff") - _, err = consctl.Write(rawoff) + _, err := consctl.Write(rawoff) if err != nil { consctl.Close() return err