-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from nogoegst/openbsd-support
Add OpenBSD support
- Loading branch information
Showing
5 changed files
with
73 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// +build darwin freebsd linux solaris | ||
// +build darwin freebsd linux openbsd solaris | ||
|
||
package console | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// +build openbsd,cgo | ||
|
||
package console | ||
|
||
import ( | ||
"os" | ||
|
||
"golang.org/x/sys/unix" | ||
) | ||
|
||
//#include <stdlib.h> | ||
import "C" | ||
|
||
const ( | ||
cmdTcGet = unix.TIOCGETA | ||
cmdTcSet = unix.TIOCSETA | ||
) | ||
|
||
// ptsname retrieves the name of the first available pts for the given master. | ||
func ptsname(f *os.File) (string, error) { | ||
ptspath, err := C.ptsname(C.int(f.Fd())) | ||
if err != nil { | ||
return "", err | ||
} | ||
return C.GoString(ptspath), nil | ||
} | ||
|
||
// unlockpt unlocks the slave pseudoterminal device corresponding to the master pseudoterminal referred to by f. | ||
// unlockpt should be called before opening the slave side of a pty. | ||
func unlockpt(f *os.File) error { | ||
if _, err := C.grantpt(C.int(f.Fd())); err != nil { | ||
return err | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// +build openbsd,!cgo | ||
|
||
// | ||
// Implementing the functions below requires cgo support. Non-cgo stubs | ||
// versions are defined below to enable cross-compilation of source code | ||
// that depends on these functions, but the resultant cross-compiled | ||
// binaries cannot actually be used. If the stub function(s) below are | ||
// actually invoked they will display an error message and cause the | ||
// calling process to exit. | ||
// | ||
|
||
package console | ||
|
||
import ( | ||
"os" | ||
|
||
"golang.org/x/sys/unix" | ||
) | ||
|
||
const ( | ||
cmdTcGet = unix.TIOCGETA | ||
cmdTcSet = unix.TIOCSETA | ||
) | ||
|
||
func ptsname(f *os.File) (string, error) { | ||
panic("ptsname() support requires cgo.") | ||
} | ||
|
||
func unlockpt(f *os.File) error { | ||
panic("unlockpt() support requires cgo.") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// +build darwin freebsd linux solaris | ||
// +build darwin freebsd linux openbsd solaris | ||
|
||
package console | ||
|
||
|