leakless

package module
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2020 License: MIT Imports: 12 Imported by: 18

README

leakless

Run sub-process and make sure to kill it when the parent process exits. The way how it works is to output a standalone executable file to guard the subprocess and check parent TCP connection with a UUID. So that it works consistently on Linux, Mac, and Windows.

Not using the PID is because after a process exits, a newly created process may have the same PID.

How to Use

See the examples.

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Support added in v0.5.5

func Support() bool

Support returns true if the OS is supported by leakless.

Types

type Launcher added in v0.2.0

type Launcher struct {
	// contains filtered or unexported fields
}

Launcher struct

func New

func New() *Launcher

New leakless instance

Example
package main

import (
	"fmt"
	"time"

	"github.com/ysmood/leakless"
)

func main() {
	ll := leakless.New()

	// just like using the exec.Command
	_ = ll.Command("sleep", "3").Start()

	// get the pid of the guarded sub-process
	select {
	case <-time.Tick(3 * time.Second):
		panic("timeout")
	case pid := <-ll.Pid():
		fmt.Println(pid)
	}
}

func (*Launcher) Command added in v0.2.0

func (l *Launcher) Command(name string, arg ...string) *exec.Cmd

Command will try to download the leakless bin and prefix the exec.Cmd with the leakless options.

func (*Launcher) Err added in v0.5.1

func (l *Launcher) Err() string

Err message from the guard process

func (*Launcher) Pid added in v0.2.0

func (l *Launcher) Pid() chan int

Pid signals the pid of the guarded sub-process. The channel may never receive the pid.

Directories

Path Synopsis
cmd
leakless command
pack command
test command
zombie command

Jump to

Keyboard shortcuts

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