aboutsummaryrefslogtreecommitdiff
path: root/src/os/exec/exec.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/os/exec/exec.go')
-rw-r--r--src/os/exec/exec.go13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/os/exec/exec.go b/src/os/exec/exec.go
index 30fd64a4b1..424b49cf06 100644
--- a/src/os/exec/exec.go
+++ b/src/os/exec/exec.go
@@ -404,11 +404,14 @@ func (c *Cmd) Start() error {
c.closeDescriptors(c.closeAfterStart)
- c.errch = make(chan error, len(c.goroutine))
- for _, fn := range c.goroutine {
- go func(fn func() error) {
- c.errch <- fn()
- }(fn)
+ // Don't allocate the channel unless there are goroutines to fire.
+ if len(c.goroutine) > 0 {
+ c.errch = make(chan error, len(c.goroutine))
+ for _, fn := range c.goroutine {
+ go func(fn func() error) {
+ c.errch <- fn()
+ }(fn)
+ }
}
if c.ctx != nil {