Skip to content
Closed
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
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
language: go
sudo: required
dist: bionic

go:
Expand Down
11 changes: 11 additions & 0 deletions pkg/invoke/os_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,16 @@

package invoke

import (
"os"
"syscall"
)

// Valid file extensions for plugin executables.
var ExecutableFileExtensions = []string{""}

// SysProcAttribute holds optional, operating system-specific attributes.
var SysProcAttribute = &syscall.SysProcAttr{
Setpgid: true,
Pgid: os.Getpid(),
}
7 changes: 7 additions & 0 deletions pkg/invoke/os_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,12 @@

package invoke

import (
"syscall"
)

// Valid file extensions for plugin executables.
var ExecutableFileExtensions = []string{".exe", ""}

// SysProcAttribute holds optional, operating system-specific attributes.
var SysProcAttribute = &syscall.SysProcAttr{}
4 changes: 4 additions & 0 deletions pkg/invoke/raw_exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ func (e *RawExec) ExecPlugin(ctx context.Context, pluginPath string, stdinData [
c.Stdin = bytes.NewBuffer(stdinData)
c.Stdout = stdout
c.Stderr = e.Stderr
// This attributes make sub process has group process id which is same as its parent process id,
// if we use this function in tree (libcni -> plugin -> plugin ... ), all sub processes generated
// from root process can be killed in tree recursively.
c.SysProcAttr = SysProcAttribute
if err := c.Run(); err != nil {
return nil, pluginErr(err, stdout.Bytes())
}
Expand Down
2 changes: 1 addition & 1 deletion test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ cd "$(dirname $0)"

echo -n "Running tests "
function testrun {
bash -c "umask 0; PATH=$PATH go test $@"
sudo -E bash -c "umask 000; PATH=$PATH go test $@"
}
if [ ! -z "${COVERALLS:-""}" ]; then
# coverage profile only works per-package
Expand Down