ZBLOG

local other_other_compass_flow_status_pids="" for other_compass_url in ${other_compass_urls} do local other_compass_execid=$(echo "${other_compass_url}" | awk -F 'execid=' '{print $2}') check_compass_flow_status "${kutype}"...

要根据进程的返回值打印出相应信息,你可以在循环中使用 wait 命令等待所有后台进程退出,并获取它们的返回值。然后,通过判断返回值是否为1来决定打印 “fail” 信息。下面是补充代码的示例:

local other_other_compass_flow_status_pids=""
for other_compass_url in ${other_compass_urls}; do
    local other_compass_execid=$(echo "${other_compass_url}" | awk -F 'execid=' '{print $2}')
    check_compass_flow_status "${kutype}" "${other_compass_execid}" "${other_compass_url}" "all" &
    other_other_compass_flow_status_pids="${other_other_compass_flow_status_pids} $!"
done

# 等待所有后台进程退出,并获取它们的返回值
for pid in ${other_other_compass_flow_status_pids}; do
    wait "$pid"
    ret_code=$?
    if [ "$ret_code" -eq 1 ]; then
        echo "Fail"
    fi
done

在上述代码中,我们将每个子进程的 PID 添加到 other_other_compass_flow_status_pids 变量中,并使用循环遍历该变量。对于每个 PID,我们使用 wait 命令等待其退出,并获取其返回值。如果返回值为1,则打印 “Fail” 信息。

请注意,在这段代码中,check_compass_flow_status 函数可能会异步执行并返回结果。因此,在等待子进程退出之前,确保 check_compass_flow_status 函数已经执行完毕并设置了正确的返回值。


内容由零声教学AI助手提供,问题来源于学员提问

本站部分文章来源于网络,版权归原作者所有,如有侵权请联系站长删除。
转载请注明出处:https://sdn.0voice.com/?id=2846

分享:
扫描分享到社交APP
上一篇
下一篇
发表列表
游客 游客
此处应有掌声~
评论列表

还没有评论,快来说点什么吧~

联系我们

在线咨询: 点击这里给我发消息

微信号:3007537140

上班时间: 10:30-22:30

关注我们
x

注册

已经有帐号?