#!/bin/bash
# pid - process ID file support

set -e

sys_pid_config_init() {
	lib_setting_vars -ro rundir
	rundir="/home/zwelch/src/mcf/mcsh-release/install/run/mcsh"
}


######
# Process ID Support

pid_children() {
	local ppid=$1
	ps x -o pid,ppid | awk "\$2 == \"$ppid\" { print \$1 }"
}


######
# Process ID file support

pid_exists() { has_args 1 "$@"; [ -f "$rundir/$1" ]; }
pid_read() { has_args 2 "$@"; $pretend || read $1 <"$rundir/$2"; }
pid_save() { has_args 2 "$@"; $pretend || echo "$1" >"$rundir/$2"; }
pid_remove() { has_args 1 "$@"; run rm -f "$rundir/$1"; }

pid_kill() {
	min_args 2 "$@"
	local sig=$1
	local file=$2
	local hold=${3:-false}

	local pid
	pid_read pid "$file"
	run kill -$sig $pid

	! $hold || wait $pid

	pid_remove "$file"

}

View the Developer Guide Index

View the Reference Manual Index


Generated on Fri Jul 28 14:36:03 PDT 2017 by mcsh d14 v0.23.0.