beam/examples/beamsh: support for background commands with '&' terminator
Docker-DCO-1.1-Signed-off-by: Solomon Hykes <solomon@docker.com> (github: shykes)
This commit is contained in:
parent
086724e1a3
commit
529e741f08
2 changed files with 16 additions and 3 deletions
|
@ -136,9 +136,19 @@ func scriptString(script []*dockerscript.Command) string {
|
|||
func executeScript(client *net.UnixConn, script []*dockerscript.Command) error {
|
||||
Debugf("executeScript(%s)\n", scriptString(script))
|
||||
defer Debugf("executeScript(%s) DONE\n", scriptString(script))
|
||||
var background sync.WaitGroup
|
||||
defer background.Wait()
|
||||
for _, cmd := range script {
|
||||
if err := executeCommand(client, cmd); err != nil {
|
||||
return err
|
||||
if cmd.Background {
|
||||
background.Add(1)
|
||||
go func(client *net.UnixConn, cmd *dockerscript.Command) {
|
||||
executeCommand(client, cmd)
|
||||
background.Done()
|
||||
}(client, cmd)
|
||||
} else {
|
||||
if err := executeCommand(client, cmd); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue