LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   exit codes (https://www.linuxquestions.org/questions/programming-9/exit-codes-321326/)

introuble 05-08-2005 11:34 AM

exit codes
 
most programs exit 0 on success and non 0 on failure . what if we have some sort of server wich is password protected . on every new connection , a child process is spawned . the child process asks for a password and gets an incorrect one . after this , it will shutdown the socket and exit . question is .. should it exit 0 or non 0 ? is a bad password considered "failure" or not ? wich cases are considered program failures ?

grupoapunte 05-08-2005 11:49 AM

Thats more like a personal decision, if you need to say someway that the password was wrong you could make an exit(EXIT_FAILURE); (i think thats the name of the constant) , if the succed of the program dependes on a succesfull logon, you can consider that if it fails, the program fails too, cuz it couldent fullfill it's objective.

I hope i was in some way helfull for you, Dam.

jim mcnamara 05-08-2005 12:53 PM

There is a convention that is defined for error return codes.
They are defined in sysexits.h For example bad user data like a password that you want to exit with error is
Code:

exit( EX_USAGE);
see:
http://www.tmk.com/ftp/multinet-cont...ude/sysexits.h


All times are GMT -5. The time now is 06:57 PM.