Source file src/pkg/os/exec.go
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. 4 5 package os 6 7 import ( 8 "runtime" 9 "syscall" 10 ) 11 12 // Process stores the information about a process created by StartProcess. 13 type Process struct { 14 Pid int 15 handle int 16 done bool // process has been successfuly waited on 17 } 18 19 func newProcess(pid, handle int) *Process { 20 p := &Process{Pid: pid, handle: handle} 21 runtime.SetFinalizer(p, (*Process).Release) 22 return p 23 } 24 25 // ProcAttr holds the attributes that will be applied to a new process 26 // started by StartProcess. 27 type ProcAttr struct { 28 // If Dir is non-empty, the child changes into the directory before 29 // creating the process. 30 Dir string 31 // If Env is non-nil, it gives the environment variables for the 32 // new process in the form returned by Environ. 33 // If it is nil, the result of Environ will be used. 34 Env []string 35 // Files specifies the open files inherited by the new process. The 36 // first three entries correspond to standard input, standard output, and 37 // standard error. An implementation may support additional entries, 38 // depending on the underlying operating system. A nil entry corresponds 39 // to that file being closed when the process starts. 40 Files []*File 41 42 // Operating system-specific process creation attributes. 43 // Note that setting this field means that your program 44 // may not execute properly or even compile on some 45 // operating systems. 46 Sys *syscall.SysProcAttr 47 } 48 49 // A Signal can represent any operating system signal. 50 type Signal interface { 51 String() string 52 } 53 54 // Getpid returns the process id of the caller. 55 func Getpid() int { return syscall.Getpid() } 56 57 // Getppid returns the process id of the caller's parent. 58 func Getppid() int { return syscall.Getppid() }