mirror of
				https://github.com/k3s-io/kubernetes.git
				synced 2025-10-30 21:30:16 +00:00 
			
		
		
		
	godep restore pushd $GOPATH/src/github.com/appc/spec git co master popd go get go4.org/errorutil rm -rf Godeps godep save ./... git add vendor git add -f $(git ls-files --other vendor/) git co -- Godeps/LICENSES Godeps/.license_file_state Godeps/OWNERS
		
			
				
	
	
		
			47 lines
		
	
	
		
			866 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			47 lines
		
	
	
		
			866 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| package pty
 | |
| 
 | |
| import (
 | |
| 	"os"
 | |
| 	"strconv"
 | |
| 	"syscall"
 | |
| 	"unsafe"
 | |
| )
 | |
| 
 | |
| 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
 | |
| 	}
 | |
| 
 | |
| 	sname, err := ptsname(p)
 | |
| 	if err != nil {
 | |
| 		return nil, nil, err
 | |
| 	}
 | |
| 
 | |
| 	err = unlockpt(p)
 | |
| 	if err != nil {
 | |
| 		return nil, nil, err
 | |
| 	}
 | |
| 
 | |
| 	t, err := os.OpenFile(sname, os.O_RDWR|syscall.O_NOCTTY, 0)
 | |
| 	if err != nil {
 | |
| 		return nil, nil, err
 | |
| 	}
 | |
| 	return p, t, nil
 | |
| }
 | |
| 
 | |
| func ptsname(f *os.File) (string, error) {
 | |
| 	var n _C_uint
 | |
| 	err := ioctl(f.Fd(), syscall.TIOCGPTN, uintptr(unsafe.Pointer(&n)))
 | |
| 	if err != nil {
 | |
| 		return "", err
 | |
| 	}
 | |
| 	return "/dev/pts/" + strconv.Itoa(int(n)), nil
 | |
| }
 | |
| 
 | |
| func unlockpt(f *os.File) error {
 | |
| 	var u _C_int
 | |
| 	// use TIOCSPTLCK with a zero valued arg to clear the slave pty lock
 | |
| 	return ioctl(f.Fd(), syscall.TIOCSPTLCK, uintptr(unsafe.Pointer(&u)))
 | |
| }
 |