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
68a024b5
Commit
68a024b5
authored
May 07, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
packer/plugin: Make sure subprocess properly dies if error
parent
2ff1fabb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
0 deletions
+19
-0
packer/plugin/command.go
packer/plugin/command.go
+18
-0
packer/plugin/command_test.go
packer/plugin/command_test.go
+1
-0
No files found.
packer/plugin/command.go
View file @
68a024b5
...
...
@@ -11,7 +11,25 @@ import (
"time"
)
// Returns a valid packer.Command where the command is executed via RPC
// to a plugin that is within a subprocess.
//
// This method will start the given exec.Cmd, which should point to
// the plugin binary to execute. Some configuration will be done to
// the command, such as overriding Stdout and some environmental variables.
//
// This function guarantees the subprocess will end in a timely manner.
func
Command
(
cmd
*
exec
.
Cmd
)
(
result
packer
.
Command
,
err
error
)
{
// Make sure the command is properly cleaned up in the case of
// an error.
defer
func
()
{
if
err
!=
nil
{
if
cmd
.
Process
!=
nil
{
cmd
.
Process
.
Kill
()
}
}
}()
env
:=
[]
string
{
"PACKER_PLUGIN_MIN_PORT=10000"
,
"PACKER_PLUGIN_MAX_PORT=25000"
,
...
...
packer/plugin/command_test.go
View file @
68a024b5
...
...
@@ -6,6 +6,7 @@ import (
"testing"
)
// TODO: Test command cleanup functionality
// TODO: Test timeout functionality
func
TestCommand_NoExist
(
t
*
testing
.
T
)
{
...
...
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