Skip to content

Commit

Permalink
plugin: tweak stdout spawn order
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Phillips committed Apr 26, 2017
1 parent 996ccdc commit 2f19579
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions check/check_plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,15 @@ func (ch *PluginCheck) Run() (*ResultSet, error) {
ch.setupEnvironment(cmd)

// Set I/O
cmd.Stdin = r
stdout, err := cmd.StdoutPipe()
if err != nil {
crs.SetStateUnavailable()
crs.SetStatus(err.Error())
return crs, nil
}
cmd.Stdin = r
stdoutReadDone := make(chan struct{})
go ch.handleStdout(stdout, stdoutReadDone, crs)

// Start process
if err := cmd.Start(); err != nil {
Expand All @@ -180,9 +182,6 @@ func (ch *PluginCheck) Run() (*ResultSet, error) {
// Close stdin
r.Close()

stdoutReadDone := make(chan struct{})
go ch.handleStdout(stdout, stdoutReadDone, crs)

// Wait for commmand to finish
var errorFlag bool
if err := cmd.Wait(); err != nil {
Expand Down

0 comments on commit 2f19579

Please sign in to comment.