Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
packer
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kristopher Ruzic
packer
Commits
ffcb7afb
Commit
ffcb7afb
authored
Jun 02, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
provisioner/shell: Properly handle closed channels in select
parent
6bcd5de6
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
9 deletions
+22
-9
provisioner/shell/provisioner.go
provisioner/shell/provisioner.go
+22
-9
No files found.
provisioner/shell/provisioner.go
View file @
ffcb7afb
...
@@ -64,25 +64,38 @@ func (p *Provisioner) Provision(ui packer.Ui, comm packer.Communicator) {
...
@@ -64,25 +64,38 @@ func (p *Provisioner) Provision(ui packer.Ui, comm packer.Communicator) {
stderr
:=
cmd
.
StderrChan
()
stderr
:=
cmd
.
StderrChan
()
stdout
:=
cmd
.
StdoutChan
()
stdout
:=
cmd
.
StdoutChan
()
OutputLoop
:
for
{
for
{
select
{
select
{
case
output
:=
<-
stderr
:
case
output
,
ok
:=
<-
stderr
:
if
!
ok
{
stderr
=
nil
}
else
{
ui
.
Say
(
output
)
ui
.
Say
(
output
)
case
output
:=
<-
stdout
:
}
case
output
,
ok
:=
<-
stdout
:
if
!
ok
{
stdout
=
nil
}
else
{
ui
.
Say
(
output
)
ui
.
Say
(
output
)
}
case
exitStatus
:=
<-
exit
:
case
exitStatus
:=
<-
exit
:
log
.
Printf
(
"shell provisioner exited with status %d"
,
exitStatus
)
log
.
Printf
(
"shell provisioner exited with status %d"
,
exitStatus
)
break
break
OutputLoop
}
}
}
}
// Make sure we finish off stdout/stderr because we may have gotten
// Make sure we finish off stdout/stderr because we may have gotten
// a message from the exit channel first.
// a message from the exit channel first.
if
stdout
!=
nil
{
for
output
:=
range
stdout
{
for
output
:=
range
stdout
{
ui
.
Say
(
output
)
ui
.
Say
(
output
)
}
}
}
if
stderr
!=
nil
{
for
output
:=
range
stderr
{
for
output
:=
range
stderr
{
ui
.
Say
(
output
)
ui
.
Say
(
output
)
}
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment