diff options
Diffstat (limited to 'libgo/go/syscall')
-rw-r--r-- | libgo/go/syscall/exec_bsd.go | 6 | ||||
-rw-r--r-- | libgo/go/syscall/exec_linux.go | 9 | ||||
-rw-r--r-- | libgo/go/syscall/exec_unix.go | 6 | ||||
-rw-r--r-- | libgo/go/syscall/exec_windows.go | 2 | ||||
-rw-r--r-- | libgo/go/syscall/libcall_linux.go | 2 | ||||
-rw-r--r-- | libgo/go/syscall/libcall_posix.go | 6 | ||||
-rw-r--r-- | libgo/go/syscall/signame.c | 40 | ||||
-rw-r--r-- | libgo/go/syscall/socket.go | 12 | ||||
-rw-r--r-- | libgo/go/syscall/syscall_unix.go | 12 |
9 files changed, 82 insertions, 13 deletions
diff --git a/libgo/go/syscall/exec_bsd.go b/libgo/go/syscall/exec_bsd.go index 68143536182..f1f7a188de2 100644 --- a/libgo/go/syscall/exec_bsd.go +++ b/libgo/go/syscall/exec_bsd.go @@ -38,8 +38,10 @@ func forkAndExecInChild(argv0 *byte, argv, envv []*byte, chroot, dir *byte, attr i int ) - // guard against side effects of shuffling fds below. - fd := append([]int(nil), attr.Files...) + fd := make([]int, len(attr.Files)) + for i, ufd := range attr.Files { + fd[i] = int(ufd) + } // About to call fork. // No more allocation or calls of non-assembly functions. diff --git a/libgo/go/syscall/exec_linux.go b/libgo/go/syscall/exec_linux.go index cc3cfdb0805..a6c4427a59f 100644 --- a/libgo/go/syscall/exec_linux.go +++ b/libgo/go/syscall/exec_linux.go @@ -21,7 +21,7 @@ type SysProcAttr struct { Setpgid bool // Set process group ID to new pid (SYSV setpgrp) Setctty bool // Set controlling terminal to fd 0 Noctty bool // Detach fd 0 from controlling terminal - Pdeathsig int // Signal that the process will get when its parent dies (Linux only) + Pdeathsig Signal // Signal that the process will get when its parent dies (Linux only) } // Fork, dup fd onto 0..len(fd), and exec(argv0, argvv, envv) in child. @@ -43,7 +43,10 @@ func forkAndExecInChild(argv0 *byte, argv, envv []*byte, chroot, dir *byte, attr ) // guard against side effects of shuffling fds below. - fd := append([]int(nil), attr.Files...) + fd := make([]int, len(attr.Files)) + for i, ufd := range attr.Files { + fd[i] = int(ufd) + } // About to call fork. // No more allocation or calls of non-assembly functions. @@ -61,7 +64,7 @@ func forkAndExecInChild(argv0 *byte, argv, envv []*byte, chroot, dir *byte, attr // Parent death signal if sys.Pdeathsig != 0 { - _, err1 = raw_prctl(PR_SET_PDEATHSIG, sys.Pdeathsig, 0, 0, 0) + _, err1 = raw_prctl(PR_SET_PDEATHSIG, int(sys.Pdeathsig), 0, 0, 0) if err1 != 0 { goto childerror } diff --git a/libgo/go/syscall/exec_unix.go b/libgo/go/syscall/exec_unix.go index 49441f8e1c4..664908d1310 100644 --- a/libgo/go/syscall/exec_unix.go +++ b/libgo/go/syscall/exec_unix.go @@ -141,9 +141,9 @@ type Credential struct { // ProcAttr holds attributes that will be applied to a new process started // by StartProcess. type ProcAttr struct { - Dir string // Current working directory. - Env []string // Environment. - Files []int // File descriptors. + Dir string // Current working directory. + Env []string // Environment. + Files []uintptr // File descriptors. Sys *SysProcAttr } diff --git a/libgo/go/syscall/exec_windows.go b/libgo/go/syscall/exec_windows.go index 6cb25a7d00a..4dc4d059d7e 100644 --- a/libgo/go/syscall/exec_windows.go +++ b/libgo/go/syscall/exec_windows.go @@ -220,7 +220,7 @@ func joinExeDirAndFName(dir, p string) (name string, err error) { type ProcAttr struct { Dir string Env []string - Files []Handle + Files []uintptr Sys *SysProcAttr } diff --git a/libgo/go/syscall/libcall_linux.go b/libgo/go/syscall/libcall_linux.go index cb04eac9036..bb960731f75 100644 --- a/libgo/go/syscall/libcall_linux.go +++ b/libgo/go/syscall/libcall_linux.go @@ -335,7 +335,7 @@ func Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n i //sys Tee(rfd int, wfd int, len int, flags int) (n int64, err error) //tee(rfd int, wfd int, len Size_t, flags uint) Ssize_t -func Tgkill(tgid, tid, sig int) error { +func Tgkill(tgid, tid, sig Signal) error { r1, _, errno := Syscall(SYS_TGKILL, uintptr(tgid), uintptr(tid), uintptr(sig)) if r1 < 0 { return errno diff --git a/libgo/go/syscall/libcall_posix.go b/libgo/go/syscall/libcall_posix.go index 3901fe094eb..92feae0c102 100644 --- a/libgo/go/syscall/libcall_posix.go +++ b/libgo/go/syscall/libcall_posix.go @@ -128,8 +128,8 @@ func (w WaitStatus) Stopped() bool func (w WaitStatus) Continued() bool func (w WaitStatus) CoreDump() bool func (w WaitStatus) ExitStatus() int -func (w WaitStatus) Signal() int -func (w WaitStatus) StopSignal() int +func (w WaitStatus) Signal() Signal +func (w WaitStatus) StopSignal() Signal func (w WaitStatus) TrapCause() int //sys Mkfifo(path string, mode uint32) (err error) @@ -253,7 +253,7 @@ func Gettimeofday(tv *Timeval) (err error) { //sysnb Getuid() (uid int) //getuid() Uid_t -//sysnb Kill(pid int, sig int) (err error) +//sysnb Kill(pid int, sig Signal) (err error) //kill(pid Pid_t, sig int) int //sys Lchown(path string, uid int, gid int) (err error) diff --git a/libgo/go/syscall/signame.c b/libgo/go/syscall/signame.c new file mode 100644 index 00000000000..f2ff85a9a02 --- /dev/null +++ b/libgo/go/syscall/signame.c @@ -0,0 +1,40 @@ +/* signame.c -- get the name of a signal + + Copyright 2012 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. */ + +#include <string.h> + +#include "config.h" +#include "runtime.h" +#include "arch.h" +#include "malloc.h" + +String Signame (int sig) asm ("libgo_syscall.syscall.Signame"); + +String +Signame (int sig) +{ + const char* s = NULL; + char buf[100]; + size_t len; + unsigned char *data; + String ret; + +#if defined(HAVE_STRSIGNAL) + s = strsignal (sig); +#endif + + if (s == NULL) + { + snprintf(buf, sizeof buf, "signal %d", sig); + s = buf; + } + len = __builtin_strlen (s); + data = runtime_mallocgc (len, FlagNoPointers, 0, 0); + __builtin_memcpy (data, s, len); + ret.__data = data; + ret.__length = len; + return ret; +} diff --git a/libgo/go/syscall/socket.go b/libgo/go/syscall/socket.go index 7a2e95ca2a2..6d36e3985f3 100644 --- a/libgo/go/syscall/socket.go +++ b/libgo/go/syscall/socket.go @@ -217,6 +217,13 @@ func Socketpair(domain, typ, proto int) (fd [2]int, err error) { //sys getsockopt(s int, level int, name int, val uintptr, vallen *Socklen_t) (err error) //getsockopt(s int, level int, name int, val *byte, vallen *Socklen_t) int +func GetsockoptByte(fd, level, opt int) (value byte, err error) { + var n byte + vallen := Socklen_t(1) + err = getsockopt(fd, level, opt, uintptr(unsafe.Pointer(&n)), &vallen) + return n, err +} + func GetsockoptInt(fd, level, opt int) (value int, err error) { var n int32 vallen := Socklen_t(4) @@ -254,6 +261,11 @@ func GetsockoptIPv6Mreq(fd, level, opt int) (*IPv6Mreq, error) { //sys setsockopt(s int, level int, name int, val *byte, vallen Socklen_t) (err error) //setsockopt(s int, level int, optname int, val *byte, vallen Socklen_t) int +func SetsockoptByte(fd, level, opt int, value byte) (err error) { + var n = byte(value) + return setsockopt(fd, level, opt, (*byte)(unsafe.Pointer(&n)), 1) +} + func SetsockoptInt(fd, level, opt int, value int) (err error) { var n = int32(value) return setsockopt(fd, level, opt, (*byte)(unsafe.Pointer(&n)), 4) diff --git a/libgo/go/syscall/syscall_unix.go b/libgo/go/syscall/syscall_unix.go index 98e7d689f77..85182b764b0 100644 --- a/libgo/go/syscall/syscall_unix.go +++ b/libgo/go/syscall/syscall_unix.go @@ -163,3 +163,15 @@ func Mmap(fd int, offset int64, length int, prot int, flags int) (data []byte, e func Munmap(b []byte) (err error) { return mapper.Munmap(b) } + +// A Signal is a number describing a process signal. +// It implements the os.Signal interface. +type Signal int + +func (s Signal) Signal() {} + +func Signame(s Signal) string + +func (s Signal) String() string { + return Signame(s) +} |