Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions testserver/exec_linux.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright 2021 The Cockroach Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
// implied. See the License for the specific language governing
// permissions and limitations under the License.

// +build linux

package testserver

import (
"os/exec"
"syscall"
)

// execCommand attaches the Pdeathsig to tear down the cockroach cluster if the
// parent process dies.
func execCommand(name string, args ...string) *exec.Cmd {
cmd := exec.Command(name, args...)
cmd.SysProcAttr.Pdeathsig = syscall.SIGKILL
return cmd
}
23 changes: 23 additions & 0 deletions testserver/exec_not_linux.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright 2021 The Cockroach Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
// implied. See the License for the specific language governing
// permissions and limitations under the License.

// +build !linux

package testserver

import "os/exec"

func execCommand(name string, args ...string) *exec.Cmd {
return exec.Command(name, args...)
}
5 changes: 2 additions & 3 deletions testserver/testserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,9 @@ import (
"testing"
"time"

"github.com/cockroachdb/cockroach-go/v2/testserver/version"
// Import postgres driver.
_ "github.com/lib/pq"

"github.com/cockroachdb/cockroach-go/v2/testserver/version"
)

var customBinaryFlag = flag.String("cockroach-binary", "", "Use specified cockroach binary")
Expand Down Expand Up @@ -438,7 +437,7 @@ func (ts *testServerImpl) Start() error {
ts.state = stateRunning
ts.mu.Unlock()

ts.cmd = exec.Command(ts.cmdArgs[0], ts.cmdArgs[1:]...)
ts.cmd = execCommand(ts.cmdArgs[0], ts.cmdArgs[1:]...)
ts.cmd.Env = []string{"COCKROACH_MAX_OFFSET=1ns"}

if len(ts.stdout) > 0 {
Expand Down