The standard knows only two standard return values: EXIT_SUCCESS (or zero) and EXIT_- FAILURE :
3.6.1 / 5 The return statement basically has the effect of moving away from the main function (destroying any objects with automatic storage time) and calling std::exit with the return value as an argument.
18.5 / 8 (...) Finally, control returns to the host environment. If the status is zero or EXIT_SUCCESS , the presentation form that defines the implementation returns successful completion. If the status is EXIT_- FAILURE , the implementation determined by the form of the status failure returns. Otherwise, the return status is determined by the implementation .
Therefore, it is not guaranteed that any other integer is returned as is.
On MS Windows , for example GetExitCodeProcess() returns an integer value, so you get 300.
On POSIX- compatible systems, such as Linux , the rule is that ("only the 8 least significant bits (that is, status and 0377) will be available only for the parent processβ)). So for 300, it will be 44.
source share