aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/exec/exec.go
diff options
context:
space:
mode:
authorBrad Fitzpatrick <bradfitz@golang.org>2011-10-06 11:00:02 -0700
committerBrad Fitzpatrick <bradfitz@golang.org>2011-10-06 11:00:02 -0700
commit155e21cc7f37ade106171ac53fd6826869811001 (patch)
tree9281c3fe24b61d0c09d00318a174971ca1ae8148 /src/pkg/exec/exec.go
parent029c9bcb8bbf4b9dd55293d9b41fc1c16994b3f9 (diff)
downloadgo-155e21cc7f37ade106171ac53fd6826869811001.tar.xz
exec: add Command.ExtraFiles
Allows passing extra fds to the child process. Fixes #2329 R=rsc, dsymonds CC=golang-dev https://golang.org/cl/5162050
Diffstat (limited to 'src/pkg/exec/exec.go')
-rw-r--r--src/pkg/exec/exec.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/pkg/exec/exec.go b/src/pkg/exec/exec.go
index 3b20f2008c..aaad50846e 100644
--- a/src/pkg/exec/exec.go
+++ b/src/pkg/exec/exec.go
@@ -63,6 +63,11 @@ type Cmd struct {
Stdout io.Writer
Stderr io.Writer
+ // ExtraFiles specifies additional open files to be inherited by the
+ // new process. It does not include standard input, standard output, or
+ // standard error. If non-nil, entry i becomes file descriptor 3+i.
+ ExtraFiles []*os.File
+
// SysProcAttr holds optional, operating system-specific attributes.
// Run passes it to os.StartProcess as the os.ProcAttr's Sys field.
SysProcAttr *syscall.SysProcAttr
@@ -224,6 +229,7 @@ func (c *Cmd) Start() os.Error {
}
c.childFiles = append(c.childFiles, fd)
}
+ c.childFiles = append(c.childFiles, c.ExtraFiles...)
var err os.Error
c.Process, err = os.StartProcess(c.Path, c.argv(), &os.ProcAttr{