Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

go: update to build on macOS #3333

Merged
merged 1 commit into from
Sep 29, 2020
Merged
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 .changelog/3333.internal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
go: Update to build on macOS
6 changes: 2 additions & 4 deletions go/common/crypto/signature/signers/plugin/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import (
"net/rpc"
"os/exec"
"sync"
"syscall"

hclog "github.com/hashicorp/go-hclog"
"github.com/hashicorp/go-plugin"

"github.com/oasisprotocol/oasis-core/go/common/crypto/signature"
"github.com/oasisprotocol/oasis-core/go/common/syscall"
)

const (
Expand Down Expand Up @@ -94,9 +94,7 @@ func NewFactory(config interface{}, roles ...signature.SignerRole) (signature.Si
// We do use managed plugins so that in the graceful exit case,
// the cleanup will be done at least.
cmd := exec.Command(cfg.Path) // nolint: gosec
cmd.SysProcAttr = &syscall.SysProcAttr{
Pdeathsig: syscall.SIGKILL,
}
cmd.SysProcAttr = syscall.CmdAttrs

client := plugin.NewClient(&plugin.ClientConfig{
HandshakeConfig: handshakeConfigForName(cfg.Name),
Expand Down
12 changes: 12 additions & 0 deletions go/common/syscall/syscall_darwin.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Package syscall defines OS-specific syscall parameters.
package syscall

import "syscall"

// IoctlTermiosGetAttr is the ioctl that implements termios tcgetattr.
const IoctlTermiosGetAttr = syscall.TIOCGETA
peterjgilbert marked this conversation as resolved.
Show resolved Hide resolved

// CmdAttrs is the SysProcAttr used for spawning child processes. It is empty
// for Darwin as PR_SET_PDEATH_SIG is not implemented. As a consequence, child
// processes may not be cleaned up.
var CmdAttrs = &syscall.SysProcAttr{}
12 changes: 12 additions & 0 deletions go/common/syscall/syscall_linux.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Package syscall defines OS-specific syscall parameters.
package syscall

import "syscall"

// IoctlTermiosGetAttr is the ioctl that implements termios tcgetattr.
const IoctlTermiosGetAttr = syscall.TCGETS
peterjgilbert marked this conversation as resolved.
Show resolved Hide resolved

// CmdAttrs is the SysProcAttr that will ensure graceful cleanup (on Linux).
var CmdAttrs = &syscall.SysProcAttr{
Pdeathsig: syscall.SIGKILL,
}
4 changes: 3 additions & 1 deletion go/oasis-node/cmd/common/isatty.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package common
import (
"syscall"
"unsafe"

cmnSyscall "github.com/oasisprotocol/oasis-core/go/common/syscall"
)

// Isatty returns true iff the provided file descriptor is a terminal.
Expand All @@ -20,7 +22,7 @@ func Isatty(fd uintptr) bool {
_, _, errno := syscall.Syscall6(
syscall.SYS_IOCTL,
fd,
syscall.TCGETS,
cmnSyscall.IoctlTermiosGetAttr,
uintptr(unsafe.Pointer(&attrs)),
0,
0,
Expand Down
8 changes: 4 additions & 4 deletions go/oasis-test-runner/env/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ import (
"time"

flag "github.com/spf13/pflag"

cmnSyscall "github.com/oasisprotocol/oasis-core/go/common/syscall"
)

// ErrEarlyTerm is the error passed over the error channel when a
// sub-process terminates prior to the Cleanup.
var ErrEarlyTerm = errors.New("env: sub-process exited early")

// CmdAttrs is the SysProcAttr that will ensure graceful cleanup.
var CmdAttrs = &syscall.SysProcAttr{
Pdeathsig: syscall.SIGKILL,
}
// CmdAttrs is the SysProcAttr that will ensure graceful cleanup (on Linux).
var CmdAttrs = cmnSyscall.CmdAttrs

// CleanupFn is the cleanup hook function prototype.
type CleanupFn func()
Expand Down