Blog coding and discussion of coding about JavaScript, PHP, CGI, general web building etc.

Saturday, November 26, 2016

What

What "standard" application return/exit codes should an application support?


Is there such thing as a standard set of application return codes? Things like returning 0 for success 1 for failure, and then so on?

I have a Windows Server application that I am adding some return error codes and wanted to stick to standard codes in addition to the app specific ones that I will need.

Answer by Douglas Leeder for What "standard" application return/exit codes should an application support?


I think the only standard is 0 for success and non-zero for failure. And that's more of a convention than a standard.

Answer by David for What "standard" application return/exit codes should an application support?


There is no such thing as a standard set of exit codes that applications should conform to.

http://forums11.itrc.hp.com/service/forums/questionanswer.do?admit=109447626+1255018889157+28353475&threadId=1029356

However, there are some common ones like 0 for success as you mentioned. Depending on the Operating System and tools you use, you may be able to look at the exit codes for similar apps and mimic them.

Answer by Will Eddins for What "standard" application return/exit codes should an application support?


Exit codes are far from standard, and are more used for the developer to know the appropriate error that has occurred upon return of the application. The standard of 0 for success, non-zero for failure is a general trend, and is used as it lets you use the full non-zero range for all possible errors.

If your application logs errors appropriately, the exit code will likely be completely unnecessary to keep track of.

Answer by Laurence Gonsalves for What "standard" application return/exit codes should an application support?


The standard status code are EXIT_SUCCESS and EXIT_FAILURE, defined in stdlib.h. Pretty much everyone just uses 0 and 1 respectively, though. Some software will use different non-zero code for different types of errors.

Answer by Stephane Grenier for What "standard" application return/exit codes should an application support?


Implement what you'll use. Anything else is superfluous.

Answer by gioele for What "standard" application return/exit codes should an application support?


Maybe you can adopt some of the Unix conventions.

In another answer, the user David suggested

sysexits.h has a list of standard exit codes. It seems to date back to at least 1993 and some big projects like Postfix use it, so I imagine it's the way to go.

From the OpenBSD man page:

According to style(9), it is not good practice to call exit(3) with arbi- trary values to indicate a failure condition when ending a program. In- stead, the pre-defined exit codes from sysexits should be used, so the caller of the process can get a rough estimation about the failure class without looking up the source code.

This is the list as it appears on a Debian system:

#define EX_USAGE        64      /* command line usage error */  #define EX_DATAERR      65      /* data format error */  #define EX_NOINPUT      66      /* cannot open input */      #define EX_NOUSER       67      /* addressee unknown */      #define EX_NOHOST       68      /* host name unknown */  #define EX_UNAVAILABLE  69      /* service unavailable */  #define EX_SOFTWARE     70      /* internal software error */  #define EX_OSERR        71      /* system error (e.g., can't fork) */  #define EX_OSFILE       72      /* critical OS file missing */  #define EX_CANTCREAT    73      /* can't create (user) output file */  #define EX_IOERR        74      /* input/output error */  #define EX_TEMPFAIL     75      /* temp failure; user is invited to retry */  #define EX_PROTOCOL     76      /* remote error in protocol */  #define EX_NOPERM       77      /* permission denied */  #define EX_CONFIG       78      /* configuration error */  

Inside the file /usr/include/sysexits.h one can find more detailed descriptions of these error codes.

Answer by Pyro for What "standard" application return/exit codes should an application support?


There definitely are standard error codes defined for Windows.

A long time ago we used negative errors for specific 'custom' errors, but I doubt that that is good practice.

System Error Codes (Windows)


Fatal error: Call to a member function getElementsByTagName() on a non-object in D:\XAMPP INSTALLASTION\xampp\htdocs\endunpratama9i\www-stackoverflow-info-proses.php on line 72

0 comments:

Post a Comment

Popular Posts

Powered by Blogger.