Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1799)

Side by Side Diff: src/pkg/os/exec_posix.go

Issue 5688046: code review 5688046: os: drop the Wait function and the options to Process.Wait (Closed)
Patch Set: diff -r 8ce97b044cfa https://code.google.com/p/go Created 13 years, 1 month ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/pkg/os/exec_plan9.go ('k') | src/pkg/os/exec_unix.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2009 The Go Authors. All rights reserved. 1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 // +build darwin freebsd linux netbsd openbsd windows 5 // +build darwin freebsd linux netbsd openbsd windows
6 6
7 package os 7 package os
8 8
9 import ( 9 import (
10 "syscall" 10 "syscall"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 // since syscall one might have different field types across 49 // since syscall one might have different field types across
50 // different OS. 50 // different OS.
51 51
52 // Waitmsg stores the information about an exited process as reported by Wait. 52 // Waitmsg stores the information about an exited process as reported by Wait.
53 type Waitmsg struct { 53 type Waitmsg struct {
54 Pid int // The process's id. 54 Pid int // The process's id.
55 syscall.WaitStatus // System-dependent status info. 55 syscall.WaitStatus // System-dependent status info.
56 Rusage *syscall.Rusage // System-dependent resource usage in fo. 56 Rusage *syscall.Rusage // System-dependent resource usage in fo.
57 } 57 }
58 58
59 // Wait waits for process pid to exit or stop, and then returns a
60 // Waitmsg describing its status and an error, if any. The options
61 // (WNOHANG etc.) affect the behavior of the Wait call.
62 // Wait is equivalent to calling FindProcess and then Wait
63 // and Release on the result.
64 func Wait(pid int, options int) (w *Waitmsg, err error) {
65 p, e := FindProcess(pid)
66 if e != nil {
67 return nil, e
68 }
69 defer p.Release()
70 return p.Wait(options)
71 }
72
73 // Convert i to decimal string. 59 // Convert i to decimal string.
74 func itod(i int) string { 60 func itod(i int) string {
75 if i == 0 { 61 if i == 0 {
76 return "0" 62 return "0"
77 } 63 }
78 64
79 u := uint64(i) 65 u := uint64(i)
80 if i < 0 { 66 if i < 0 {
81 u = -u 67 u = -u
82 } 68 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 res += " (trap " + itod(w.TrapCause()) + ")" 100 res += " (trap " + itod(w.TrapCause()) + ")"
115 } 101 }
116 case w.Continued(): 102 case w.Continued():
117 res = "continued" 103 res = "continued"
118 } 104 }
119 if w.CoreDump() { 105 if w.CoreDump() {
120 res += " (core dumped)" 106 res += " (core dumped)"
121 } 107 }
122 return res 108 return res
123 } 109 }
OLDNEW
« no previous file with comments | « src/pkg/os/exec_plan9.go ('k') | src/pkg/os/exec_unix.go » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b