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.
14 // Process stores the information about a process created by StartProcess.
17 handle
uintptr // handle is accessed atomically on Windows
18 isdone
uint32 // process has been successfully waited on, non zero if true
19 sigMu sync
.RWMutex
// avoid race between wait and signal
22 func newProcess(pid
int, handle
uintptr) *Process
{
23 p
:= &Process
{Pid
: pid
, handle
: handle
}
24 runtime
.SetFinalizer(p
, (*Process
).Release
)
28 func (p
*Process
) setDone() {
29 atomic
.StoreUint32(&p
.isdone
, 1)
32 func (p
*Process
) done() bool {
33 return atomic
.LoadUint32(&p
.isdone
) > 0
36 // ProcAttr holds the attributes that will be applied to a new process
37 // started by StartProcess.
38 type ProcAttr
struct {
39 // If Dir is non-empty, the child changes into the directory before
40 // creating the process.
42 // If Env is non-nil, it gives the environment variables for the
43 // new process in the form returned by Environ.
44 // If it is nil, the result of Environ will be used.
46 // Files specifies the open files inherited by the new process. The
47 // first three entries correspond to standard input, standard output, and
48 // standard error. An implementation may support additional entries,
49 // depending on the underlying operating system. A nil entry corresponds
50 // to that file being closed when the process starts.
53 // Operating system-specific process creation attributes.
54 // Note that setting this field means that your program
55 // may not execute properly or even compile on some
57 Sys
*syscall
.SysProcAttr
60 // A Signal represents an operating system signal.
61 // The usual underlying implementation is operating system-dependent:
62 // on Unix it is syscall.Signal.
63 type Signal
interface {
65 Signal() // to distinguish from other Stringers
68 // Getpid returns the process id of the caller.
69 func Getpid() int { return syscall
.Getpid() }
71 // Getppid returns the process id of the caller's parent.
72 func Getppid() int { return syscall
.Getppid() }