summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2019-11-08 10:25:50 +0100
committerErich Eckner <git@eckner.net>2019-11-08 10:25:50 +0100
commit3165987f7aedd4bc154e40c0a1fd8f088b772dae (patch)
tree41e9daa5a2a8be234f44a4366e1ea1a85742bf98
parent589466d672ee09a1ef5bcd2a2e34d7a7ea7f7ef6 (diff)
downloadupdate-all-3165987f7aedd4bc154e40c0a1fd8f088b772dae.tar.xz
update-all.in: update pids list, exit when empty
-rw-r--r--update-all.in24
1 files changed, 22 insertions, 2 deletions
diff --git a/update-all.in b/update-all.in
index 352fd9f..bb87ece 100644
--- a/update-all.in
+++ b/update-all.in
@@ -57,8 +57,28 @@ if [ -z "${DISPLAY}" ]; then
)
fi
-while kill -0 "${pids[@]}"; do
- sleep 1
+while [ -n "${pids[*]}" ]; do
+ if [ -z "${DISPLAY}" ]; then
+ for pid in "${pids[@]}"; do
+ if ! kill -0 "${pid}" >/dev/null 2>&1; then
+ continue
+ fi
+ npids+=("${pid}")
+ screen -r "${pid}"
+ done
+ pids=("${npids[@]}")
+ else
+ sleep 1
+ fi
+ pids=(
+ $(
+ for pid in "${pids[@]}"; do
+ if kill -0 "${pid}" >/dev/null 2>&1; then
+ printf '%s\n' "${pid}"
+ fi
+ done
+ )
+ )
done
ls "${tmp_dir}" \