diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2018-02-08 15:30:22 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2018-02-08 15:30:22 +0000 |
commit | 9adab5dd169afd191efd1dcbf50dae0f726a0a42 (patch) | |
tree | 55e1207fb22e51fd55c08d7f337c1822acf46f7b /libgo/go/os | |
parent | b5ec4de777870e2d4ff2a5de604eafd1bf0e50df (diff) | |
download | gcc-9adab5dd169afd191efd1dcbf50dae0f726a0a42.zip gcc-9adab5dd169afd191efd1dcbf50dae0f726a0a42.tar.gz gcc-9adab5dd169afd191efd1dcbf50dae0f726a0a42.tar.bz2 |
libgo: update to Go1.10rc2
Reviewed-on: https://go-review.googlesource.com/92736
From-SVN: r257493
Diffstat (limited to 'libgo/go/os')
-rw-r--r-- | libgo/go/os/exec.go | 5 | ||||
-rw-r--r-- | libgo/go/os/exec/exec.go | 5 | ||||
-rw-r--r-- | libgo/go/os/signal/internal/pty/pty.go | 20 | ||||
-rw-r--r-- | libgo/go/os/signal/signal_cgo_test.go | 4 |
4 files changed, 31 insertions, 3 deletions
diff --git a/libgo/go/os/exec.go b/libgo/go/os/exec.go index b3f60b6..a7f8710 100644 --- a/libgo/go/os/exec.go +++ b/libgo/go/os/exec.go @@ -88,6 +88,11 @@ func FindProcess(pid int) (*Process, error) { // specified by name, argv and attr. The argv slice will become os.Args in the // new process, so it normally starts with the program name. // +// If the calling goroutine has locked the operating system thread +// with runtime.LockOSThread and modified any inheritable OS-level +// thread state (for example, Linux or Plan 9 name spaces), the new +// process will inherit the caller's thread state. +// // StartProcess is a low-level interface. The os/exec package provides // higher-level interfaces. // diff --git a/libgo/go/os/exec/exec.go b/libgo/go/os/exec/exec.go index 8a49fe3..5ef9540 100644 --- a/libgo/go/os/exec/exec.go +++ b/libgo/go/os/exec/exec.go @@ -293,6 +293,11 @@ func (c *Cmd) closeDescriptors(closers []io.Closer) { // // If the command starts but does not complete successfully, the error is of // type *ExitError. Other error types may be returned for other situations. +// +// If the calling goroutine has locked the operating system thread +// with runtime.LockOSThread and modified any inheritable OS-level +// thread state (for example, Linux or Plan 9 name spaces), the new +// process will inherit the caller's thread state. func (c *Cmd) Run() error { if err := c.Start(); err != nil { return err diff --git a/libgo/go/os/signal/internal/pty/pty.go b/libgo/go/os/signal/internal/pty/pty.go index 1c3480c..e52d19a 100644 --- a/libgo/go/os/signal/internal/pty/pty.go +++ b/libgo/go/os/signal/internal/pty/pty.go @@ -33,21 +33,35 @@ func close(int32) int32 const _O_RDWR = 2 +type PtyError struct { + FuncName string + ErrorString string + Errno syscall.Errno +} + +func ptyError(name string, err error) *PtyError { + return &PtyError{name, err.Error(), err.(syscall.Errno)} +} + +func (e *PtyError) Error() string { + return fmt.Sprintf("%s: %s", e.FuncName, e.ErrorString) +} + // Open returns a master pty and the name of the linked slave tty. func Open() (master *os.File, slave string, err error) { m := posix_openpt(_O_RDWR) if m < 0 { - return nil, "", fmt.Errorf("posix_openpt: %v", syscall.GetErrno()) + return nil, "", ptyError("posix_openpt", syscall.GetErrno()) } if grantpt(m) < 0 { errno := syscall.GetErrno() close(m) - return nil, "", fmt.Errorf("grantpt: %v", errno) + return nil, "", ptyError("grantpt", errno) } if unlockpt(m) < 0 { errno := syscall.GetErrno() close(m) - return nil, "", fmt.Errorf("unlockpt: %v", errno) + return nil, "", ptyError("unlockpt", errno) } p := ptsname(m) s := (*[32000]byte)(unsafe.Pointer(p))[:] diff --git a/libgo/go/os/signal/signal_cgo_test.go b/libgo/go/os/signal/signal_cgo_test.go index 27707fa..84a2a08 100644 --- a/libgo/go/os/signal/signal_cgo_test.go +++ b/libgo/go/os/signal/signal_cgo_test.go @@ -72,6 +72,10 @@ func TestTerminalSignal(t *testing.T) { master, sname, err := pty.Open() if err != nil { + ptyErr := err.(*pty.PtyError) + if ptyErr.FuncName == "posix_openpt" && ptyErr.Errno == syscall.EACCES { + t.Skip("posix_openpt failed with EACCES, assuming chroot and skipping") + } t.Fatal(err) } defer master.Close() |