kexec

package module
v0.0.0-...-5a4bed9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 19, 2018 License: MIT Imports: 7 Imported by: 21 modules, 19 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

kexec

GoDoc

This is a golang lib, add a Terminate command to exec.

Tested on windows, linux, darwin.

This lib has been used in fswatch.

Usage

go get -v github.com/codeskyblue/kexec

example1:

package main

import "github.com/codeskyblue/kexec"

func main(){
	p := kexec.Command("python", "flask_main.py")
	p.Start()
	p.Terminate(syscall.SIGINT)
}

example2: see more examples

package main

import (
	"github.com/codeskyblue/kexec"
)

func main() {
	// In unix will call: bash -c "python flask_main.py"
	// In windows will call: cmd /c "python flask_main.py"
	p := kexec.CommandString("python flask_main.py")
	p.Stdout = os.Stdout
	p.Stderr = os.Stderr
	p.Start()
	p.Terminate(syscall.SIGKILL)
}

example3:

package main

import "github.com/codeskyblue/kexec"

func main() {
	p := kexec.Command("whoami")
	p.SetUser("codeskyblue") // Only works on darwin and linux
	p.Run()
}

Command line usage

$ go get -v github.com/codeskyblue/kexec/cmds/kexec
$ kexec python main.py
# Ctrl+C
python is terminating ...

PS

This lib also support you call Wait() twice, which is not support by os/exec

LICENSE

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type KCommand

type KCommand struct {
	*exec.Cmd
	// contains filtered or unexported fields
}

func Command

func Command(name string, arg ...string) *KCommand

func CommandString

func CommandString(command string) *KCommand

func (*KCommand) Run

func (c *KCommand) Run() error

func (*KCommand) Terminate

func (p *KCommand) Terminate(sig os.Signal) (err error)

func (*KCommand) Wait

func (k *KCommand) Wait() error

This Wait wraps exec.Wait, but support multi call

Directories

Path Synopsis
cmds
kexec command
Tornado ignore signal CTRL-C, so I write this program
Tornado ignore signal CTRL-C, so I write this program

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址