@@ -1,6 +1,6 @@
# Makefile.am -- Go library Makefile.
-# Copyright 2009 The Go Authors. All rights reserved.
+# Copyright 2009, 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.
@@ -1206,7 +1210,7 @@
endif # !LIBGO_IS_LINUX
-# Define ForkExec, PtraceForkExec, Exec, and Wait4.
+# Define ForkExec, PtraceForkExec, Exec, and Waitpid.
if LIBGO_IS_RTEMS
syscall_exec_os_file = syscalls/exec_stubs.go
else
@@ -1,4 +1,4 @@
-// Copyright 2009 The Go Authors. All rights reserved.
+// Copyright 2009, 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.
@@ -22,7 +22,7 @@
// Linux's ptrace(2) interface. The implementation is multi-threaded.
// Each attached process has an associated monitor thread, and each
// running attached thread has an associated "wait" thread. The wait
-// thread calls wait4 on the thread's TID and reports any wait events
+// thread calls waitpid on the thread's TID and reports any wait events
// or errors via "debug events". The monitor thread consumes these
// wait events and updates the internally maintained state of each
// thread. All ptrace calls must run in the monitor thread, so the
@@ -1,4 +1,4 @@
-// Copyright 2009 The Go Authors. All rights reserved.
+// Copyright 2009, 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.
@@ -65,16 +65,11 @@
// TODO(rsc): Should os implement its own syscall.WaitStatus
// wrapper with the methods, or is exposing the underlying one enough?
-//
-// TODO(rsc): Certainly need to have Rusage struct,
-// since syscall one might have different field types across
-// different OS.
// Waitmsg stores the information about an exited process as reported by Wait.
type Waitmsg struct {
Pid int // The process's id.
syscall.WaitStatus // System-dependent status info.
- Rusage *syscall.Rusage // System-dependent resource usage info.
}
// Wait waits for process pid to exit or stop, and then returns a
@@ -1,4 +1,4 @@
-// Copyright 2009 The Go Authors. All rights reserved.
+// Copyright 2009, 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.
@@ -14,13 +14,8 @@
WNOHANG = syscall.WNOHANG // Don't wait if no process has exited.
WSTOPPED = syscall.WSTOPPED // If set, status of stopped subprocesses is also reported.
WUNTRACED = syscall.WUNTRACED // Usually an alias for WSTOPPED.
- WRUSAGE = 1 << 20 // Record resource usage.
)
-// WRUSAGE must not be too high a bit, to avoid clashing with Linux's
-// WCLONE, WALL, and WNOTHREAD flags, which sit in the top few bits of
-// the options
-
// Wait waits for the Process to exit or stop, and then returns a
// Waitmsg describing its status and an Error, if any. The options
// (WNOHANG etc.) affect the behavior of the Wait call.
@@ -29,19 +24,13 @@
return nil, EINVAL
}
var status syscall.WaitStatus
- var rusage *syscall.Rusage
- if options&WRUSAGE != 0 {
- rusage = new(syscall.Rusage)
- options ^= WRUSAGE
- }
- pid1, e := syscall.Wait4(p.Pid, &status, options, rusage)
+ pid1, e := syscall.Waitpid(p.Pid, &status, options)
if e != 0 {
return nil, NewSyscallError("wait", e)
}
w = new(Waitmsg)
w.Pid = pid1
w.WaitStatus = status
- w.Rusage = rusage
return w, nil
}
@@ -1,6 +1,6 @@
#!/bin/sh
-# Copyright 2009 The Go Authors. All rights reserved.
+# Copyright 2009, 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.
@@ -355,30 +372,6 @@
>> ${OUT}
echo "type DIR _DIR" >> ${OUT}
-# The rusage struct.
-rusage=`grep '^type _rusage struct' gen-sysinfo.go`
-if test "$rusage" != ""; then
- rusage=`echo $rusage | sed -e 's/type _rusage struct //' -e 's/[{}]//g'`
- rusage=`echo $rusage | sed -e 's/^ *//'`
- nrusage=
- while test -n "$rusage"; do
- field=`echo $rusage | sed -e 's/^\([^;]*\);.*$/\1/'`
- rusage=`echo $rusage | sed -e 's/^[^;]*; *\(.*\)$/\1/'`
- # Drop the leading ru_, capitalize the next character.
- field=`echo $field | sed -e 's/^ru_//'`
- f=`echo $field | sed -e 's/^\(.\).*$/\1/'`
- r=`echo $field | sed -e 's/^.\(.*\)$/\1/'`
- f=`echo $f | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ`
- # Fix _timeval _timespec, and _timestruc_t.
- r=`echo $r | sed -e s'/ _timeval$/ Timeval/'`
- r=`echo $r | sed -e s'/ _timespec$/ Timespec/'`
- r=`echo $r | sed -e s'/ _timestruc_t$/ Timestruc/'`
- field="$f$r"
- nrusage="$nrusage $field;"
- done
- echo "type Rusage struct {$nrusage }" >> ${OUT}
-fi
-
# The utsname struct.
grep '^type _utsname ' gen-sysinfo.go | \
sed -e 's/_utsname/Utsname/' \
@@ -1,6 +1,6 @@
// exec.go -- fork/exec syscall support.
-// Copyright 2009 The Go Authors. All rights reserved.
+// Copyright 2009, 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.
@@ -16,7 +16,7 @@
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")
+func libc_waitpid(Pid_t, *int, int) Pid_t __asm__ ("waitpid")
// 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.
@@ -204,9 +204,9 @@
// Child failed; wait for it to exit, to make sure
// the zombies don't accumulate.
- _, err1 := Wait4(pid, &wstatus, 0, nil)
+ _, err1 := Waitpid(pid, &wstatus, 0)
for err1 == EINTR {
- _, err1 = Wait4(pid, &wstatus, 0, nil)
+ _, err1 = Waitpid(pid, &wstatus, 0)
}
return 0, err
}
@@ -239,9 +239,9 @@
return pid, 0, err
}
-func Wait4(pid int, wstatus *WaitStatus, options int, rusage *Rusage) (wpid int, errno int) {
+func Waitpid(pid int, wstatus *WaitStatus, options int) (wpid int, errno int) {
var status int
- r := libc_wait4(Pid_t(pid), &status, options, rusage)
+ r := libc_waitpid(Pid_t(pid), &status, options)
wpid = int(r)
if r < 0 {
errno = GetErrno()
@@ -1,6 +1,6 @@
// exec_stubs.go -- fork/exec stubs.
-// Copyright 2010 The Go Authors. All rights reserved.
+// Copyright 2010, 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.
@@ -20,6 +20,6 @@
return ENOSYS;
}
-func Wait4(pid int, wstatus *WaitStatus, options int, rusage *Rusage) (wpid int, errno int) {
+func Waitpid(pid int, wstatus *WaitStatus, options int) (wpid int, errno int) {
return -1, ENOSYS;
}