Values greater than 125 have special meanings, so cap it there. Unit
tests and lib tests use the number of failures as the return code, so a
large number of failures (such as test 2601 as a torture test) can
exceed this causing the test to be erroneously reported as having
failed.
Ref: #10720
_flushall();
#endif
- return result;
+ /* Regular program status codes are limited to 0..127 and 126 and 127 have
+ * special meanings by the shell, so limit a normal return code to 125 */
+ return result <= 125 ? result : 125;
}