Skip to content

nxsre/kexec

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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()
}

PS

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

LICENSE

MIT

About

Killable os/exec for golang library.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 96.7%
  • Python 3.3%