Skip to content

Commit 455c2f3

Browse files
committed
Some bugfixes for "bugout trap"
- Added a sleep to the controller goroutine. Without this, bugout trap was saturating a whole CPU core. - Increased buffer size to 1 kib for stream goroutines. Without this, stdout and stderr were getting eaten up on exit. This is a quick fix.
1 parent 7a3a5b5 commit 455c2f3

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

cmd/bugout/trap/invoke.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"os/exec"
77
"os/signal"
88
"strings"
9+
"time"
910

1011
"github.com/spf13/cobra"
1112
)
@@ -17,7 +18,7 @@ type InvocationResult struct {
1718
}
1819

1920
func stream(reader io.Reader, writer io.Writer, doneChan chan<- bool, cancelChan <-chan bool) {
20-
b := make([]byte, 1)
21+
b := make([]byte, 1024)
2122
for {
2223
select {
2324
case <-cancelChan:
@@ -97,6 +98,8 @@ func RunWrappedCommand(trapCmd *cobra.Command, invocation []string) (*Invocation
9798
exitChannel <- 1
9899
}
99100
return
101+
} else {
102+
time.Sleep(10 * time.Millisecond)
100103
}
101104
}
102105
}

pkg/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
package bugout
22

3-
const Version string = "0.3.1"
3+
const Version string = "0.3.2"

0 commit comments

Comments
 (0)