process

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: May 25, 2023 License: MIT Imports: 5 Imported by: 0

README

process Package

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Daemon

func Daemon(writepid io.Writer, processArgs func([]string, ...string) []string, args ...string) (err error)

Daemon backgrounds the current process by re-executing the existing binary (as found by os.Executable, so may there is a small window while the referenced binary can change). The function passed as processArgs is called with any further arguments passed to it as parameters and can be used to remove flags that triggered the daemonisation in the first place. A helper function - RemoveArgs - is available to do this.

If successful the function never returns and the child process PID is written to writepid, which can be io.Discard if not required. On failure the function does return with an error.

process.Daemon(os.Stdout, process.RemoveArgs, "-D", "--daemon")

func RemoveArgs

func RemoveArgs(in []string, remove ...string) (out []string)

RemoveArgs is a helper function for Daemon(). Daemon calls the function with os.Args[1;] as in and removes any arguments matching members of the slice remove and returns out. Only bare arguments are removed and no pattern matching or adjacent values are removed. If this is required then pass your own function with the same signature.

Types

This section is empty.

Jump to

Keyboard shortcuts

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