So I have a program that may or may not segfault (./segf) that also writes other data to stderr. When the program segfaults, its return code is 139 (i.e.
echo $? will print
I would like to redirect stderr to
/dev/null so as to avoid printing it, however doing so (
./segf 2>1) causes the return code to be set to 1. Now it's impossible to differentiate whether the program is truly segfaulting or just returning an error.
Is it possible to pipe stderr's other errors while still being able to check that the return code would be 139?
./segf >/dev/null; echo $? results in 139
./segf >/dev/null 2>1; echo $? results in 1
bash -c './segf' results in 139
bash -c './segf' 2>1 results in 1