aboutsummaryrefslogtreecommitdiffstats
path: root/ipc/ipc.go
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2017-05-23 14:01:54 +0200
committerDmitry Vyukov <dvyukov@google.com>2017-05-23 14:01:54 +0200
commitecebe18fc3a6e2b94ece456a6618beeac54f4a63 (patch)
tree0d3a896bbdbcb4bb76f789255a08ed990881e10f /ipc/ipc.go
parent6117e48187f8d8719376dee3e863fa701fd4d784 (diff)
ipc: fix test build
Diffstat (limited to 'ipc/ipc.go')
-rw-r--r--ipc/ipc.go24
1 files changed, 16 insertions, 8 deletions
diff --git a/ipc/ipc.go b/ipc/ipc.go
index 847a798b6..377beddda 100644
--- a/ipc/ipc.go
+++ b/ipc/ipc.go
@@ -66,8 +66,8 @@ var (
// Executor can be slow due to global locks in namespaces and other things,
// so let's better wait than report false misleading crashes.
flagTimeout = flag.Duration("timeout", 1*time.Minute, "execution timeout")
- flagAbortSignal = flag.Int("abort_signal", int(syscall.SIGKILL), "initial signal to send to executor in error conditions; upgrades to SIGKILL if executor does not exit")
- flagBufferSize = flag.Uint64("buffer_size", 128<<10, "internal buffer size (in bytes) for executor output")
+ flagAbortSignal = flag.Int("abort_signal", 0, "initial signal to send to executor in error conditions; upgrades to SIGKILL if executor does not exit")
+ flagBufferSize = flag.Uint64("buffer_size", 0, "internal buffer size (in bytes) for executor output")
)
// ExecutorFailure is returned from MakeEnv or from env.Exec when executor terminates by calling fail function.
@@ -443,15 +443,19 @@ func makeCommand(pid int, bin []string, config Config, inFile *os.File, outFile
cmd.Stderr = wp
go func(c *command) {
// Read out output in case executor constantly prints something.
- output := make([]byte, c.config.BufferSize)
+ bufSize := c.config.BufferSize
+ if bufSize == 0 {
+ bufSize = 128 << 10
+ }
+ output := make([]byte, bufSize)
var size uint64
for {
n, err := rp.Read(output[size:])
if n > 0 {
size += uint64(n)
- if size >= c.config.BufferSize*3/4 {
- copy(output, output[size-c.config.BufferSize/2:size])
- size = c.config.BufferSize / 2
+ if size >= bufSize*3/4 {
+ copy(output, output[size-bufSize/2:size])
+ size = bufSize / 2
}
}
if err != nil {
@@ -533,8 +537,12 @@ func (c *command) waitServing() error {
// abort sends the abort signal to the command and then SIGKILL if wait doesn't
// return within 5s.
func (c *command) abort() {
- syscall.Kill(c.cmd.Process.Pid, c.config.AbortSignal)
- if c.config.AbortSignal != syscall.SIGKILL {
+ sig := c.config.AbortSignal
+ if sig <= 0 || sig >= 32 {
+ sig = syscall.SIGKILL
+ }
+ syscall.Kill(c.cmd.Process.Pid, sig)
+ if sig != syscall.SIGKILL {
go func() {
t := time.NewTimer(5 * time.Second)
select {