sysmgr

a simplistic service supervisor
git clone git://git.ckyln.com/~cem/sysmgr.git
Log | Files | Refs | README | LICENSE

commit 31ab171d44df9b58c35458440cbbfae64b09be19
parent 9138df62f3623e71af5a317fb530886ae6ac4bc9
Author: Cem Keylan <cem@ckyln.com>
Date:   Thu, 27 Feb 2020 20:35:23 +0300

add documentation to checkprocess

Diffstat:
Msysmgr | 12++++++++++++
1 file changed, 12 insertions(+), 0 deletions(-)

diff --git a/sysmgr b/sysmgr @@ -25,6 +25,18 @@ SYSDIR="${SYSDIR:-/var/sysmgr}" version=0.1.1 checkprocess() { + + # This function checks if the process is still alive and + # returns 0 or 1 accordingly. It checks the /proc directory + # first (which exists in most Linux systems, but not all) + # and fallbacks to kill if it doesn't. There are three + # reasons for preferring /proc over kill: + # + # 1: We don't need to spawn an extra process. + # 2: We can check processes we don't own, which eliminates + # the requirement of being root. + # 3: Checking the existence of a directory is much faster and + # more efficient than sending a signal to a process. [ -d /proc ] || { kill -0 "$1" || return 1 return 0