LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 05-08-2005, 12:34 PM   #1
introuble
Member
 
Registered: Apr 2004
Distribution: Debian -unstable
Posts: 700

Rep: Reputation: 31
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 ?
 
Old 05-08-2005, 12:49 PM   #2
grupoapunte
LQ Newbie
 
Registered: Apr 2005
Posts: 26

Rep: Reputation: 15
Lightbulb

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.
 
Old 05-08-2005, 01:53 PM   #3
jim mcnamara
Member
 
Registered: May 2002
Posts: 964

Rep: Reputation: 34
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
difference between exit 1 and exit kushalkoolwal Programming 6 10-20-2005 04:56 PM
Are the hex codes for colors in a jpg the same codes as used in html? abefroman Linux - Security 3 07-31-2005 04:21 PM
Slackware codes NooDleZ Slackware 6 03-13-2005 05:56 PM
How to Compare the c/c++ codes muneebs123 Programming 4 02-19-2004 01:53 AM
source codes eltongeoff Linux - Newbie 3 12-07-2003 06:17 PM


All times are GMT -5. The time now is 11:50 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration