From 6f9976598dbdda23c229633bca5622326b556ea3 Mon Sep 17 00:00:00 2001 From: Yifan Gao Date: Tue, 23 Jun 2020 00:14:13 +0800 Subject: [PATCH] exit with non-zero child thread status code --- common.sh | 15 ++++++++++++++- generate.sh | 2 +- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/common.sh b/common.sh index ef00ea22..ac1ccf39 100755 --- a/common.sh +++ b/common.sh @@ -38,5 +38,18 @@ prepare_data(){ curl -sSL https://bgp.potaroo.net/cidr/autnums.html | awk '-F[<>]' '{print $3,$5}' | grep '^AS' > asnames.txt & prepare_data_v4 & prepare_data_v6 & - wait + wait_exit +} + +wait_exit(){ + local oldstate=$(set +o) + set +e + local s=0 + while [[ $s -ne 127 ]]; do + [[ $s -ne 0 ]] && exit $s + wait -n + s=$? + done + eval "$oldstate" + return 0 } diff --git a/generate.sh b/generate.sh index ec5ba2ad..ad6be640 100755 --- a/generate.sh +++ b/generate.sh @@ -13,4 +13,4 @@ for file in operator/*.conf; do get_asn $file | xargs bgptools -b rib6.txt | cidr-merger -s > result/${operator}6.txt & done -wait +wait_exit