From: Duffie Cooley Date: Wed, 2 Oct 2013 14:07:43 +0000 (-0700) Subject: ovs-lib: Return the exit status of ovs-ctl in ovs_ctl(). X-Git-Tag: v2.0~13 X-Git-Url: http://git.cascardo.eti.br/?p=cascardo%2Fovs.git;a=commitdiff_plain;h=0e37488562d1aca0b413cc368f3342b59b2614eb ovs-lib: Return the exit status of ovs-ctl in ovs_ctl(). commit 46528f78e5c(debian, rhel, xenserver: Ability to collect ovs-ctl logs) made changes in the startup scripts such that the o/p of ovs-ctl is logged into ovs-ctl.log. But it had an unintended consequence that the exit status of ovs-ctl was no longer returned. We would always return success(the exit status of tee). With this commit, we return the exit status of ovs-ctl instead of tee. Code referenced from: (line wrapped). http://unix.stackexchange.com/questions/14270/\ get-exit-status-of-process-thats-piped-to-another/70675#70675) Signed-off-by: Gurucharan Shetty Signed-off-by: Duffie Cooley Acked-by: Ben Pfaff --- diff --git a/utilities/ovs-lib.in b/utilities/ovs-lib.in index 1684ddcdd..0b6f42ffc 100644 --- a/utilities/ovs-lib.in +++ b/utilities/ovs-lib.in @@ -41,6 +41,11 @@ ovs_ctl_log () { echo "$@" >> "${logdir}/ovs-ctl.log" } +stdintoexitstatus () { + read exitstatus + return $exitstatus +} + ovs_ctl () { case "$@" in *"=strace"*) @@ -50,8 +55,14 @@ ovs_ctl () { "${datadir}/scripts/ovs-ctl" "$@" ;; *) + # Tee ovs-ctl output to ovs-ctl.log and yield ovs-ctl's exit + # status. See (line wrapped) + # http://unix.stackexchange.com/questions/14270/\ + # get-exit-status-of-process-thats-piped-to-another/70675#70675 echo "`date -u`:$@" >> "${logdir}/ovs-ctl.log" - "${datadir}/scripts/ovs-ctl" "$@" 2>&1 | tee -a "${logdir}/ovs-ctl.log" + ( ( ( ( ("${datadir}/scripts/ovs-ctl" "$@" 2>&1 ; echo $? >&3) \ + | tee -a "${logdir}/ovs-ctl.log") >&4) 3>&1) | stdintoexitstatus) \ + 4>&1 ;; esac }