os: drop the Wait function and the options to Process.Wait
They are portability problems and the options are almost always zero in practice anyway.

R=golang-dev, dsymonds, r, bradfitz
CC=golang-dev
https://golang.org/cl/5688046
diff --git a/src/cmd/cgo/util.go b/src/cmd/cgo/util.go
index d6b6a7a..155c659 100644
--- a/src/cmd/cgo/util.go
+++ b/src/cmd/cgo/util.go
@@ -56,7 +56,7 @@
 	<-c
 	<-c
 
-	w, err := p.Wait(0)
+	w, err := p.Wait()
 	if err != nil {
 		fatalf("%s", err)
 	}
diff --git a/src/cmd/fix/oswait.go b/src/cmd/fix/oswait.go
new file mode 100644
index 0000000..fdc23f85
--- /dev/null
+++ b/src/cmd/fix/oswait.go
@@ -0,0 +1,56 @@
+// 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 main
+
+import (
+	"go/ast"
+)
+
+func init() {
+	register(oswaitFix)
+}
+
+var oswaitFix = fix{
+	"oswait",
+	"2012-02-20",
+	oswait,
+	`Delete options from os.Wait. If the option is the literal 0, rewrite the call.
+
+http://codereview.appspot.com/5688046
+`,
+}
+
+func oswait(f *ast.File) bool {
+	if !imports(f, "os") {
+		return false
+	}
+
+	fixed := false
+
+	walk(f, func(n interface{}) {
+		call, ok := n.(*ast.CallExpr)
+		if !ok {
+			return
+		}
+		if !isPkgDot(call.Fun, "os", "Wait") {
+			return
+		}
+		args := call.Args
+		const warning = "call to Process.Wait must be fixed manually"
+		if len(args) != 1 {
+			// Shouldn't happen, but check.
+			warn(call.Pos(), warning)
+			return
+		}
+		if basicLit, ok := args[0].(*ast.BasicLit); !ok || basicLit.Value != "0" {
+			warn(call.Pos(), warning)
+			return
+		}
+		call.Args = nil
+		fixed = true
+	})
+
+	return fixed
+}
diff --git a/src/cmd/fix/oswait_test.go b/src/cmd/fix/oswait_test.go
new file mode 100644
index 0000000..baff017
--- /dev/null
+++ b/src/cmd/fix/oswait_test.go
@@ -0,0 +1,41 @@
+// 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 main
+
+func init() {
+	addTestCases(oswaitTests, oswait)
+}
+
+var oswaitTests = []testCase{
+	{
+		Name: "oswait.0",
+		In: `package main
+
+import (
+	"os"
+)
+
+func f() {
+	os.Wait()
+	os.Wait(0)
+	os.Wait(1)
+	os.Wait(A | B)
+}
+`,
+		Out: `package main
+
+import (
+	"os"
+)
+
+func f() {
+	os.Wait()
+	os.Wait()
+	os.Wait(1)
+	os.Wait(A | B)
+}
+`,
+	},
+}
diff --git a/src/cmd/godoc/main.go b/src/cmd/godoc/main.go
index 96b7299..80cf618 100644
--- a/src/cmd/godoc/main.go
+++ b/src/cmd/godoc/main.go
@@ -103,7 +103,7 @@
 
 	var buf bytes.Buffer
 	io.Copy(&buf, r)
-	wait, err := p.Wait(0)
+	wait, err := p.Wait()
 	if err != nil {
 		os.Stderr.Write(buf.Bytes())
 		log.Printf("os.Wait(%d, 0): %v", p.Pid, err)
diff --git a/src/pkg/os/exec/exec.go b/src/pkg/os/exec/exec.go
index fe25467..248d97d 100644
--- a/src/pkg/os/exec/exec.go
+++ b/src/pkg/os/exec/exec.go
@@ -291,7 +291,7 @@
 		return errors.New("exec: Wait was already called")
 	}
 	c.finished = true
-	msg, err := c.Process.Wait(0)
+	msg, err := c.Process.Wait()
 	c.Waitmsg = msg
 
 	var copyError error
diff --git a/src/pkg/os/exec_plan9.go b/src/pkg/os/exec_plan9.go
index c57c4dc..92126c1 100644
--- a/src/pkg/os/exec_plan9.go
+++ b/src/pkg/os/exec_plan9.go
@@ -70,9 +70,8 @@
 }
 
 // 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.
-func (p *Process) Wait(options int) (w *Waitmsg, err error) {
+// Waitmsg describing its status and an error, if any.
+func (p *Process) Wait() (w *Waitmsg, err error) {
 	var waitmsg syscall.Waitmsg
 
 	if p.Pid == -1 {
@@ -95,20 +94,6 @@
 	return &Waitmsg{waitmsg}, nil
 }
 
-// Wait waits for process pid 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.
-// Wait is equivalent to calling FindProcess and then Wait
-// and Release on the result.
-func Wait(pid int, options int) (w *Waitmsg, err error) {
-	p, e := FindProcess(pid)
-	if e != nil {
-		return nil, e
-	}
-	defer p.Release()
-	return p.Wait(options)
-}
-
 // Release releases any resources associated with the Process.
 func (p *Process) Release() error {
 	// NOOP for Plan 9.
diff --git a/src/pkg/os/exec_posix.go b/src/pkg/os/exec_posix.go
index 33a689e..03c7f0e 100644
--- a/src/pkg/os/exec_posix.go
+++ b/src/pkg/os/exec_posix.go
@@ -56,20 +56,6 @@
 	Rusage             *syscall.Rusage // System-dependent resource usage info.
 }
 
-// Wait waits for process pid 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.
-// Wait is equivalent to calling FindProcess and then Wait
-// and Release on the result.
-func Wait(pid int, options int) (w *Waitmsg, err error) {
-	p, e := FindProcess(pid)
-	if e != nil {
-		return nil, e
-	}
-	defer p.Release()
-	return p.Wait(options)
-}
-
 // Convert i to decimal string.
 func itod(i int) string {
 	if i == 0 {
diff --git a/src/pkg/os/exec_unix.go b/src/pkg/os/exec_unix.go
index a5c2281..b9880ff 100644
--- a/src/pkg/os/exec_unix.go
+++ b/src/pkg/os/exec_unix.go
@@ -12,43 +12,23 @@
 	"syscall"
 )
 
-// Options for Wait.
-const (
-	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.
-func (p *Process) Wait(options int) (w *Waitmsg, err error) {
+// Waitmsg describing its status and an error, if any.
+func (p *Process) Wait() (w *Waitmsg, err error) {
 	if p.Pid == -1 {
 		return nil, syscall.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.Wait4(p.Pid, &status, 0, nil)
 	if e != nil {
 		return nil, NewSyscallError("wait", e)
 	}
-	// With WNOHANG pid is 0 if child has not exited.
-	if pid1 != 0 && options&WSTOPPED == 0 {
+	if pid1 != 0 {
 		p.done = true
 	}
 	w = new(Waitmsg)
 	w.Pid = pid1
 	w.WaitStatus = status
-	w.Rusage = rusage
 	return w, nil
 }
 
diff --git a/src/pkg/os/exec_windows.go b/src/pkg/os/exec_windows.go
index 2a7affa..7d46c89 100644
--- a/src/pkg/os/exec_windows.go
+++ b/src/pkg/os/exec_windows.go
@@ -13,7 +13,7 @@
 
 // Wait waits for the Process to exit or stop, and then returns a
 // Waitmsg describing its status and an error, if any.
-func (p *Process) Wait(options int) (w *Waitmsg, err error) {
+func (p *Process) Wait() (w *Waitmsg, err error) {
 	s, e := syscall.WaitForSingleObject(syscall.Handle(p.handle), syscall.INFINITE)
 	switch s {
 	case syscall.WAIT_OBJECT_0:
diff --git a/src/pkg/os/os_test.go b/src/pkg/os/os_test.go
index e02d7a4..976d64b 100644
--- a/src/pkg/os/os_test.go
+++ b/src/pkg/os/os_test.go
@@ -541,7 +541,7 @@
 		t.Errorf("exec %q returned %q wanted %q",
 			strings.Join(append([]string{cmd}, args...), " "), output, expect)
 	}
-	p.Wait(0)
+	p.Wait()
 }
 
 func TestStartProcess(t *testing.T) {
@@ -853,7 +853,7 @@
 
 	var b bytes.Buffer
 	io.Copy(&b, r)
-	_, err = p.Wait(0)
+	_, err = p.Wait()
 	if err != nil {
 		t.Fatalf("run hostname Wait: %v", err)
 	}