diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2011-03-30 23:05:04 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2011-03-30 23:05:04 +0000 |
commit | 0b3189e79f87c6d8927a96918b2ee53456df4928 (patch) | |
tree | 96a73acd062cce5897fb331039d0cb1cb6442134 /libgo/syscalls | |
parent | 8955c80a1cc754999cfa93d03c04307281e6136f (diff) | |
download | gcc-0b3189e79f87c6d8927a96918b2ee53456df4928.zip gcc-0b3189e79f87c6d8927a96918b2ee53456df4928.tar.gz gcc-0b3189e79f87c6d8927a96918b2ee53456df4928.tar.bz2 |
libgo: Use waitpid on systems which do not have wait4.
From-SVN: r171758
Diffstat (limited to 'libgo/syscalls')
-rw-r--r-- | libgo/syscalls/exec.go | 14 | ||||
-rw-r--r-- | libgo/syscalls/wait4.go | 22 | ||||
-rw-r--r-- | libgo/syscalls/waitpid.go | 22 |
3 files changed, 44 insertions, 14 deletions
diff --git a/libgo/syscalls/exec.go b/libgo/syscalls/exec.go index 64b40bd..450c7e5 100644 --- a/libgo/syscalls/exec.go +++ b/libgo/syscalls/exec.go @@ -17,7 +17,6 @@ func libc_chdir(name *byte) int __asm__ ("chdir") func libc_dup2(int, int) int __asm__ ("dup2") func libc_execve(*byte, **byte, **byte) int __asm__ ("execve") func libc_sysexit(int) __asm__ ("_exit") -func libc_wait4(Pid_t, *int, int, *Rusage) Pid_t __asm__ ("wait4") // Fork, dup fd onto 0..len(fd), and exec(argv0, argvv, envv) in child. // If a dup or exec fails, write the errno int to pipe. @@ -263,16 +262,3 @@ func Exec(argv0 string, argv []string, envv []string) (err int) { libc_execve(StringBytePtr(argv0), &argv_arg[0], &envv_arg[0]) return GetErrno() } - -func Wait4(pid int, wstatus *WaitStatus, options int, rusage *Rusage) (wpid int, errno int) { - var status int - r := libc_wait4(Pid_t(pid), &status, options, rusage) - wpid = int(r) - if r < 0 { - errno = GetErrno() - } - if wstatus != nil { - *wstatus = WaitStatus(status) - } - return -} diff --git a/libgo/syscalls/wait4.go b/libgo/syscalls/wait4.go new file mode 100644 index 0000000..bb00c79 --- /dev/null +++ b/libgo/syscalls/wait4.go @@ -0,0 +1,22 @@ +// wait4.go -- Wait4 for systems with wait4. + +// Copyright 2011 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. + +package syscall + +func libc_wait4(Pid_t, *int, int, *Rusage) Pid_t __asm__ ("wait4") + +func Wait4(pid int, wstatus *WaitStatus, options int, rusage *Rusage) (wpid int, errno int) { + var status int + r := libc_wait4(Pid_t(pid), &status, options, rusage) + wpid = int(r) + if r < 0 { + errno = GetErrno() + } + if wstatus != nil { + *wstatus = WaitStatus(status) + } + return +} diff --git a/libgo/syscalls/waitpid.go b/libgo/syscalls/waitpid.go new file mode 100644 index 0000000..1cb4d5d --- /dev/null +++ b/libgo/syscalls/waitpid.go @@ -0,0 +1,22 @@ +// waitpid.go -- Wait4 for systems without wait4, but with waitpid. + +// Copyright 2011 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. + +package syscall + +func libc_waitpid(Pid_t, *int, int) Pid_t __asm__ ("waitpid") + +func Wait4(pid int, wstatus *WaitStatus, options int, rusage *Rusage) (wpid int, errno int) { + var status int + r := libc_waitpid(Pid_t(pid), &status, options) + wpid = int(r) + if r < 0 { + errno = GetErrno() + } + if wstatus != nil { + *wstatus = WaitStatus(status) + } + return +} |