I'm using timeout command in the Linux shell to call a program with a specific timeout.
And from the timeout command guide, it returns exit code 124 if a timeout happens, and returns the program exit code if no timeout happens. Unfortunately, the program that I call also returns exit code 124 in some cases.
So I just want to ask if we have any way to recognize if 124 is from the timeout command or program?
code:
timeout 10s program 2>&1 | tee log.txt
if [ "${PIPESTATUS[0]}" == 124 ]; then
# do something
fi
Thanks