Commits

Jack Frost  committed 452a9e6 Merge

Merge branch 'master' of github.com:fbt/pickaxe

  • Participants
  • Parent commits ea9f753, 5e1f2e8

Comments (0)

Files changed (1)

 # /config
 
 ## functions
-source '/opt/bashlib/bashlib'
+blib.sys.pid_check() {
+	[[ "$1" ]] || {
+		echo "usage: blib.sys.pid_check PID" >&2
+		return 1
+	}
+
+	ps -p "$1" &>/dev/null
+}
+
+blib.sys.pid_wait() {
+	local rc='0'
+	local timeout="$2"
+	[[ "$timeout" ]] || { timeout='30'; }
+
+	echo -n "Waiting for PID to exit: $1..."
+
+	while [[ "$counter" -lt "$timeout" ]] && { blib.sys.pid_check "$1"; }; do
+		echo -n '.'
+		sleep 1
+		local counter=$[counter+1]
+		[[ "$counter" -ge "$timeout" ]] && { echo 'timeout'; local rc='1'; }
+	done
+
+	echo; return "$rc"
+}
 
 creeper.usage() {
 	local script_name=`basename $0`