]> Cypherpunks repositories - gostls13.git/commitdiff
runtime, syscall: fix Solaris exec tests
authorAram Hăvărneanu <aram@mgk.ro>
Tue, 24 Mar 2015 17:33:37 +0000 (18:33 +0100)
committerAram Hăvărneanu <aram@mgk.ro>
Tue, 24 Mar 2015 19:51:21 +0000 (19:51 +0000)
Also fixes a long-existing problem in the fork/exec path.

Change-Id: Idec40b1cee0cfb1625fe107db3eafdc0d71798f2
Reviewed-on: https://go-review.googlesource.com/8030
Reviewed-by: Minux Ma <minux@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
src/runtime/syscall2_solaris.go
src/syscall/exec_solaris_test.go [new file with mode: 0644]
src/syscall/exec_unix_test.go
src/syscall/export_unix_test.go [new file with mode: 0644]

index 1b415166a4b4f4258682b3255113f8eae6a21034..df72996da0b12ca8bec2a58fe526cefcc82d3935 100644 (file)
@@ -22,7 +22,7 @@ import _ "unsafe" // for go:linkname
 //go:cgo_import_dynamic libc_setgroups setgroups "libc.so"
 //go:cgo_import_dynamic libc_setsid setsid "libc.so"
 //go:cgo_import_dynamic libc_setuid setuid "libc.so"
-//go:cgo_import_dynamic libc_setpgid setsid "libc.so"
+//go:cgo_import_dynamic libc_setpgid setpgid "libc.so"
 //go:cgo_import_dynamic libc_syscall syscall "libc.so"
 //go:cgo_import_dynamic libc_forkx forkx "libc.so"
 //go:cgo_import_dynamic libc_wait4 wait4 "libc.so"
diff --git a/src/syscall/exec_solaris_test.go b/src/syscall/exec_solaris_test.go
new file mode 100644 (file)
index 0000000..123d9f1
--- /dev/null
@@ -0,0 +1,29 @@
+// Copyright 2015 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build solaris
+
+package syscall
+
+var (
+       procGetpgid = modlibc.NewProc("getpgid")
+       procGetpgrp = modlibc.NewProc("getpgrp")
+)
+
+func Getpgid(pid int) (pgid int, err error) {
+       r0, _, e1 := sysvicall6(procGetpgid.Addr(), 1, uintptr(pid), 0, 0, 0, 0, 0)
+       pgid = int(r0)
+       if e1 != 0 {
+               err = e1
+       }
+       return
+}
+
+func Getpgrp() (pgrp int) {
+       r0, _, _ := sysvicall6(procGetpgrp.Addr(), 0, 0, 0, 0, 0, 0, 0)
+       pgrp = int(r0)
+       return
+}
+
+var Ioctl = ioctl
index 954d9aa26f2650e4c9acdaf4f1effdf429e767bd..ff8261111eed9d42d1b5c0b2baa31da3e0edc40e 100644 (file)
@@ -167,17 +167,12 @@ func TestForeground(t *testing.T) {
 
        tty, err := os.OpenFile("/dev/tty", os.O_RDWR, 0)
        if err != nil {
-               t.Skipf("Can't test Foreground. Couldn't open /dev/tty: %s",
-                       err)
+               t.Skipf("Can't test Foreground. Couldn't open /dev/tty: %s", err)
        }
 
        fpgrp := 0
 
-       _, _, errno := syscall.Syscall(syscall.SYS_IOCTL,
-               tty.Fd(),
-               syscall.TIOCGPGRP,
-               uintptr(unsafe.Pointer(&fpgrp)))
-
+       errno := syscall.Ioctl(tty.Fd(), syscall.TIOCGPGRP, uintptr(unsafe.Pointer(&fpgrp)))
        if errno != 0 {
                t.Fatalf("TIOCGPGRP failed with error code: %s", errno)
        }
@@ -212,11 +207,7 @@ func TestForeground(t *testing.T) {
 
        cmd.Stop()
 
-       _, _, errno = syscall.Syscall(syscall.SYS_IOCTL,
-               tty.Fd(),
-               syscall.TIOCSPGRP,
-               uintptr(unsafe.Pointer(&fpgrp)))
-
+       errno = syscall.Ioctl(tty.Fd(), syscall.TIOCSPGRP, uintptr(unsafe.Pointer(&fpgrp)))
        if errno != 0 {
                t.Fatalf("TIOCSPGRP failed with error code: %s", errno)
        }
diff --git a/src/syscall/export_unix_test.go b/src/syscall/export_unix_test.go
new file mode 100644 (file)
index 0000000..b41fe2f
--- /dev/null
@@ -0,0 +1,12 @@
+// Copyright 2015 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build darwin dragonfly freebsd linux netbsd openbsd
+
+package syscall
+
+func Ioctl(fd, req, arg uintptr) (err Errno) {
+       _, _, err = Syscall(SYS_IOCTL, fd, req, arg)
+       return err
+}