Questions tagged [exit-strategy]

6 questions
17
votes
7 answers

Non-zero exit status for clean exit

Is it acceptable to return a non-zero exit code if the program in question ran properly? For example, say I have a simple program that (only) does the following: Program takes N arguments. It returns an exit code of min(N, 255). Note that any N is…
Thomas Eding
  • 1,062
  • 1
  • 11
  • 18
4
votes
4 answers

Quit a program in main or in function?

Lets say I have a void method/function to check the arguments of the program: void check(int argc, String argv){ //some irrelevant code } In this function I have some checks to validate the correctness of the arguments. For example if there are…
moffeltje
  • 251
  • 3
  • 8
1
vote
3 answers

Should I use the "die" idiom in C++?

If we implement the following function: template [[noreturn]] inline bool die(std::string_view message_format = "", Ts&&... args); We can then write: if (bad_thing_happened()) die("A bad thing happened!"); or, for…
einpoklum
  • 2,478
  • 1
  • 13
  • 30
1
vote
1 answer

Which statements can be considered as exit points?

There are many discussions related to whether it is better to have only one or multiple exit points per function, but it is not clear to me which statements can be considered as exit points: only return or some other ones as well? For example,…
user90726
  • 205
  • 2
  • 9
1
vote
5 answers

How do you use exit status code?

When the program run successfully, usually the program will return 0 status. If there any problems, the we can return value other than 0 at exit. With Exceptions, (as long as the problem is not undefined behaviour), we can return 0 value even though…
Mas Bagol
  • 469
  • 4
  • 8
0
votes
0 answers

Own Exception or Delegation design pattern to exit a program?

I am writing an application in Java which use MVC pattern design. I have 4 major classes: Main, Controller, Model, View. Main initialize the other three and run launchMenu() in a infinite loop, a method included in Controller. This launchMenu from…
Jorge
  • 101
  • 1