Description

Spawn detached processes with no need to wait on them

Package Information

Version0.1.4 (2017-Mar-19)
Repositoryhttps://github.com/FreeSlave/detached
LicenseBSL-1.0
CopyrightCopyright © 2016, Roman Chistokhodov
AuthorsRoman Chistokhodov
Registered byRoman Chistokhodov
Sub packages
./examples/spawn/
[directory based sub package]
Dependencies

findexecutable

Installation

To use this package, put the following dependency into your project's dependencies section:

dub.json
dub.sdl

Readme

Detached

Spawn detached processes in D.

Build Status Windows Build Status Coverage Status

Standard D library does not provide a way to start detached process and requires to wait on returned Pid. Without waiting you will get zombie processes (resource leakage) if parent process outlives its child.

detached solves this problem by introducing the spawnProcessDetached function which has almost the same API as spawnProcess.

Features

  • Run process detached, i.e. with no need to wait.
  • Actually reports errors from exec- functions unlike spawnProcess which just checks if executable and working directory exist before fork and hopes their states leave unchanged before exec.

Missing features

  • A way to close standard streams in spawned process (e.g. for daemon creation).

Examples

Spawn

Simple program demonstrating the usage of spawnProcessDetached.

dub run :spawn  -- --workdir=/usr/local -- pwd
dub run :spawn  -- --stdout=/dev/null --stderr=/dev/null -- vlc
dub run :spawn -- -v HELLO=WORLD -- sh -c 'echo $HELLO'

Available versions

0.1.4 0.1.3 0.1.2 0.1.1 0.1.0 ~master