summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Ball <nullspoon@oper.io>2020-12-30 08:59:45 -0700
committerAaron Ball <nullspoon@oper.io>2020-12-30 08:59:45 -0700
commit751463f396e0c790b8dce73df33b00f7dccbf91f (patch)
treef7469f668f5e38714fd057f02661d4e7404a4334
parentd6522988d5c8d1bbc4c98d4d0d0f2f26dffd867f (diff)
downloadoper.io-751463f396e0c790b8dce73df33b00f7dccbf91f.tar.gz
oper.io-751463f396e0c790b8dce73df33b00f7dccbf91f.tar.xz
bash waitpid function: Simplify wait loop
-rw-r--r--posts/bash:waitpid_function.rst5
1 files changed, 1 insertions, 4 deletions
diff --git a/posts/bash:waitpid_function.rst b/posts/bash:waitpid_function.rst
index e08fbfe..350dee6 100644
--- a/posts/bash:waitpid_function.rst
+++ b/posts/bash:waitpid_function.rst
@@ -101,13 +101,10 @@ as posix c and glibc. That said, let's write our own for bash.
[ -z "${_pid}" ] && printf "Pid required\n" && return 1
[ -z "${_threshold}" ] && printf "Wait threshold required\n" && return 1
- # Check now for immediate return
- [ ! -d "/proc/${_pid}" ] && return 0
-
# Check every second up to the threshold wait time
for (( i=0; i<${_threshold}; i++ )); do
- sleep 1
[ ! -d "/proc/${_pid}" ] && return 0
+ sleep 1
done
return 1
}

Generated by cgit