Daily bump.
[official-gcc.git] / libgo / go / os / exec.go
blob5aea3098b542354d27630d1cc51b66d6efd5c2fe
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 package os
7 import (
8 "runtime"
9 "sync/atomic"
10 "syscall"
13 // Process stores the information about a process created by StartProcess.
14 type Process struct {
15 Pid int
16 handle uintptr
17 isdone uint32 // process has been successfully waited on, non zero if true
20 func newProcess(pid int, handle uintptr) *Process {
21 p := &Process{Pid: pid, handle: handle}
22 runtime.SetFinalizer(p, (*Process).Release)
23 return p
26 func (p *Process) setDone() {
27 atomic.StoreUint32(&p.isdone, 1)
30 func (p *Process) done() bool {
31 return atomic.LoadUint32(&p.isdone) > 0
34 // ProcAttr holds the attributes that will be applied to a new process
35 // started by StartProcess.
36 type ProcAttr struct {
37 // If Dir is non-empty, the child changes into the directory before
38 // creating the process.
39 Dir string
40 // If Env is non-nil, it gives the environment variables for the
41 // new process in the form returned by Environ.
42 // If it is nil, the result of Environ will be used.
43 Env []string
44 // Files specifies the open files inherited by the new process. The
45 // first three entries correspond to standard input, standard output, and
46 // standard error. An implementation may support additional entries,
47 // depending on the underlying operating system. A nil entry corresponds
48 // to that file being closed when the process starts.
49 Files []*File
51 // Operating system-specific process creation attributes.
52 // Note that setting this field means that your program
53 // may not execute properly or even compile on some
54 // operating systems.
55 Sys *syscall.SysProcAttr
58 // A Signal represents an operating system signal.
59 // The usual underlying implementation is operating system-dependent:
60 // on Unix it is syscall.Signal.
61 type Signal interface {
62 String() string
63 Signal() // to distinguish from other Stringers
66 // Getpid returns the process id of the caller.
67 func Getpid() int { return syscall.Getpid() }
69 // Getppid returns the process id of the caller's parent.
70 func Getppid() int { return syscall.Getppid() }