Browse Source

Made read nonblocking.

Beoran 4 years ago
parent
commit
a74adbc492
3 changed files with 8 additions and 2 deletions
  1. 4 1
      go.mod
  2. 2 0
      go.sum
  3. 2 1
      os/linux/input/input_linux.go

+ 4 - 1
go.mod

@@ -2,4 +2,7 @@ module gitlab.com/beoran/galago
 
 go 1.12
 
-require github.com/seccomp/libseccomp-golang v0.9.1
+require (
+	github.com/seccomp/libseccomp-golang v0.9.1
+	golang.org/x/sys v0.0.0-20190919044723-0c1ff786ef13
+)

+ 2 - 0
go.sum

@@ -1,2 +1,4 @@
 github.com/seccomp/libseccomp-golang v0.9.1 h1:NJjM5DNFOs0s3kYE1WUOr6G8V97sdt46rlXTMfXGWBo=
 github.com/seccomp/libseccomp-golang v0.9.1/go.mod h1:GbW5+tmTXfcxTToHLXlScSlAvWlF4P2Ca7zGrPiEpWo=
+golang.org/x/sys v0.0.0-20190919044723-0c1ff786ef13 h1:/zi0zzlPHWXYXrO1LjNRByFu8sdGgCkj2JLDdBIB84k=
+golang.org/x/sys v0.0.0-20190919044723-0c1ff786ef13/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=

+ 2 - 1
os/linux/input/input_linux.go

@@ -18,7 +18,8 @@ type Device struct {
 const Directory = "/dev/input"
 
 func Open(name string) (*Device, error) {
-    f, err := os.OpenFile(filepath.Join(Directory, name), os.O_RDWR, 0666)
+    f, err := os.OpenFile(filepath.Join(Directory, name), 
+        syscall.O_ASYNC|syscall.O_NONBLOCK|os.O_RDWR, 0666)
     if err != nil {
         return nil, err
     }