Sha256: 1a66367d11081dd0bcb326acce81b16773864e948aadefad0933aed11be21da7

Contents?: true

Size: 1.08 KB

Versions: 87

Compression:

Stored size: 1.08 KB

Contents

// +build !windows

package util

import (
	"os"
	"os/exec"
	"syscall"
)

// ExecCommand executes the given command with $SHELL
func ExecCommand(command string, setpgid bool) *exec.Cmd {
	shell := os.Getenv("SHELL")
	if len(shell) == 0 {
		shell = "sh"
	}
	return ExecCommandWith(shell, command, setpgid)
}

// ExecCommandWith executes the given command with the specified shell
func ExecCommandWith(shell string, command string, setpgid bool) *exec.Cmd {
	cmd := exec.Command(shell, "-c", command)
	if setpgid {
		cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
	}
	return cmd
}

// KillCommand kills the process for the given command
func KillCommand(cmd *exec.Cmd) error {
	return syscall.Kill(-cmd.Process.Pid, syscall.SIGKILL)
}

// IsWindows returns true on Windows
func IsWindows() bool {
	return false
}

// SetNonblock executes syscall.SetNonblock on file descriptor
func SetNonblock(file *os.File, nonblock bool) {
	syscall.SetNonblock(int(file.Fd()), nonblock)
}

// Read executes syscall.Read on file descriptor
func Read(fd int, b []byte) (int, error) {
	return syscall.Read(int(fd), b)
}

Version data entries

87 entries across 87 versions & 1 rubygems

Version Path
doing-2.1.88 lib/helpers/fzf/src/util/util_unix.go
doing-2.1.87 lib/helpers/fzf/src/util/util_unix.go
doing-2.1.86 lib/helpers/fzf/src/util/util_unix.go
doing-2.1.85 lib/helpers/fzf/src/util/util_unix.go
doing-2.1.84 lib/helpers/fzf/src/util/util_unix.go
doing-2.1.83 lib/helpers/fzf/src/util/util_unix.go
doing-2.1.82 lib/helpers/fzf/src/util/util_unix.go
doing-2.1.81 lib/helpers/fzf/src/util/util_unix.go
doing-2.1.80 lib/helpers/fzf/src/util/util_unix.go
doing-2.1.79 lib/helpers/fzf/src/util/util_unix.go
doing-2.1.78 lib/helpers/fzf/src/util/util_unix.go
doing-2.1.77 lib/helpers/fzf/src/util/util_unix.go
doing-2.1.76 lib/helpers/fzf/src/util/util_unix.go
doing-2.1.75 lib/helpers/fzf/src/util/util_unix.go
doing-2.1.74 lib/helpers/fzf/src/util/util_unix.go
doing-2.1.73 lib/helpers/fzf/src/util/util_unix.go
doing-2.1.72 lib/helpers/fzf/src/util/util_unix.go
doing-2.1.69 lib/helpers/fzf/src/util/util_unix.go
doing-2.1.68 lib/helpers/fzf/src/util/util_unix.go
doing-2.1.66 lib/helpers/fzf/src/util/util_unix.go