diff --git a/doc.go b/doc.go new file mode 100644 index 0000000..491c060 --- /dev/null +++ b/doc.go @@ -0,0 +1,11 @@ +// Package pty provides functions for working with Unix terminals. +package pty + +import ( + "os" +) + +// Opens a pty and its corresponding tty. +func Open() (pty, tty *os.File, err error) { + return open() +} diff --git a/pty_darwin.go b/pty_darwin.go index c94a208..597bb03 100644 --- a/pty_darwin.go +++ b/pty_darwin.go @@ -10,8 +10,7 @@ import ( // see ioccom.h const sys_IOCPARM_MASK = 0x1fff -// Opens a pty and its corresponding tty. -func Open() (pty, tty *os.File, err error) { +func open() (pty, tty *os.File, err error) { p, err := os.OpenFile("/dev/ptmx", os.O_RDWR, 0) if err != nil { return nil, nil, err diff --git a/pty_linux.go b/pty_linux.go index cecbbd6..3df1847 100644 --- a/pty_linux.go +++ b/pty_linux.go @@ -12,8 +12,7 @@ const ( sys_TIOCSPTLCK = 0x40045431 ) -// Opens a pty and its corresponding tty. -func Open() (pty, tty *os.File, err error) { +func open() (pty, tty *os.File, err error) { p, err := os.OpenFile("/dev/ptmx", os.O_RDWR, 0) if err != nil { return nil, nil, err