1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
5 // +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris
16 func (p
*Process
) wait() (ps
*ProcessState
, err error
) {
18 return nil, syscall
.EINVAL
20 var status syscall
.WaitStatus
21 var rusage syscall
.Rusage
22 pid1
, e
:= syscall
.Wait4(p
.Pid
, &status
, 0, &rusage
)
24 return nil, NewSyscallError("wait", e
)
37 var errFinished
= errors
.New("os: process already finished")
39 func (p
*Process
) signal(sig Signal
) error
{
41 return errors
.New("os: process already released")
44 return errors
.New("os: process not initialized")
49 s
, ok
:= sig
.(syscall
.Signal
)
51 return errors
.New("os: unsupported signal type")
53 if e
:= syscall
.Kill(p
.Pid
, s
); e
!= nil {
54 if e
== syscall
.ESRCH
{
62 func (p
*Process
) release() error
{
65 // no need for a finalizer anymore
66 runtime
.SetFinalizer(p
, nil)
70 func findProcess(pid
int) (p
*Process
, err error
) {
72 return newProcess(pid
, 0), nil
75 func (p
*ProcessState
) userTime() time
.Duration
{
76 return time
.Duration(p
.rusage
.Utime
.Nano()) * time
.Nanosecond
79 func (p
*ProcessState
) systemTime() time
.Duration
{
80 return time
.Duration(p
.rusage
.Stime
.Nano()) * time
.Nanosecond