Skip to content

Commit

Permalink
Prevent golang to set the non-block flag on ptmx open to avoid 100% C…
Browse files Browse the repository at this point in the history
…PU usage on reads (#53)

Signed-off-by: Guillaume J. Charmes <[email protected]>
  • Loading branch information
creack authored Oct 6, 2017
1 parent 2c10821 commit 95d05c1
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pty_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ import (
)

func open() (pty, tty *os.File, err error) {
p, err := os.OpenFile("/dev/ptmx", os.O_RDWR, 0)
pFD, err := syscall.Open("/dev/ptmx", syscall.O_RDWR|syscall.O_CLOEXEC, 0)
if err != nil {
return nil, nil, err
}
p := os.NewFile(uintptr(pFD), "/dev/ptmx")

sname, err := ptsname(p)
if err != nil {
Expand Down

0 comments on commit 95d05c1

Please sign in to comment.