timeout

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2020 License: MIT Imports: 4 Imported by: 6

Documentation

Overview

Example
package main

import (
	"context"
	"fmt"
	"os/exec"

	"github.com/suzuki-shunsuke/go-timeout/timeout"
)

func main() {
	cmd := exec.Command("true")
	runner := timeout.NewRunner(0)
	ctx, cancel := context.WithCancel(context.Background())
	defer cancel()

	if err := runner.Run(ctx, cmd); err != nil {
		fmt.Println(err)
	}
}
Output:

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type KillError

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

func (KillError) Cause

func (ke KillError) Cause() error

func (KillError) Error

func (ke KillError) Error() string

func (KillError) PID

func (ke KillError) PID() int

func (KillError) Signal

func (ke KillError) Signal() syscall.Signal

func (KillError) Unwrap added in v1.0.0

func (ke KillError) Unwrap() error

type Runner

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

func NewRunner

func NewRunner(killAfter time.Duration) *Runner

func (*Runner) Run

func (runner *Runner) Run(ctx context.Context, cmd *exec.Cmd) error

func (*Runner) SendSignal

func (runner *Runner) SendSignal(sig syscall.Signal)

func (*Runner) SetSigKillCaballback

func (runner *Runner) SetSigKillCaballback(cb func(int))

func (*Runner) SetSignal

func (runner *Runner) SetSignal(sig syscall.Signal)

type StartError

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

func (StartError) Cause

func (se StartError) Cause() error

func (StartError) Error

func (se StartError) Error() string

func (StartError) Unwrap added in v1.0.0

func (se StartError) Unwrap() error

type WaitError

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

func (WaitError) Cause

func (we WaitError) Cause() error

func (WaitError) Error

func (we WaitError) Error() string

func (WaitError) Unwrap added in v1.0.0

func (we WaitError) Unwrap() error

Jump to

Keyboard shortcuts

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