leakless

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2020 License: MIT Imports: 10 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 check parent tcp connection with an uuid.

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

How to Use

See the examples

Deploy

godev build -d ./cmd/leakless

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Leakless

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

Leakless ...

func New

func New() *Leakless

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 (*Leakless) Bin

func (l *Leakless) Bin(path string) *Leakless

Bin sets the leakless bin location

func (*Leakless) Command

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

Command will try to download the leakless bin and prefix the exec.Cmd with the leakless options. If it fails to download the bin a normal exec.Cmd will be returned.

func (*Leakless) Host

func (l *Leakless) Host(host string) *Leakless

Host sets the host to download leakless bin

func (*Leakless) Pid

func (l *Leakless) 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
test command
zombie command

Jump to

Keyboard shortcuts

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