By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,300 Members | 2,044 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,300 IT Pros & Developers. It's quick & easy.

Interpreting exit error code

P: 2

I'm a biologist who does a fair amount of hack programming. I'm not really formally trained so perhaps this question is a bit basic.

My problem is that I'm trying to understand some output I'm getting from gdb when running some C code.

Specifically, when running the code depending at the end I get the following errors:
Program exited with code 0356
Program exited with code 0355
depending on the options I use when running the code.

Besides this message, the code seems to run fine. It prints everything out, gets to the end and doesnt' give a seg fault error. Nevertheless, I would like to be sure that there isn't a serious error with the output.

I have been trying to find a table that will help me interpret these codes, but can't seem to locate one. Could someone please shed a little light on how to proceed?

Thanks in advance.

Sep 17 '08 #1
Share this Question
Share on Google+
6 Replies

Expert Mod 5K+
P: 8,916
The exit code of a program is entirely dependent on the design of the program.

The only real common denominator is that 0 tends to be a general success code. However this doesn't mean that the 2 values you are getting are errors.

  • Reading the program documentation if any exists
  • checking the code for comments or observable logic that explains the exit code
  • Asking the person that wrote the code what they meant
  • Taking a guess with-in the context that the code is running, for example a compiler often returns the number of diagnostic messages it produced

If you are looking at the third point and thinks but I wrote the code and I didn't intend that exit code then
  • Post the fully output of the program, copy and paste it
  • If it is not too long and has no copyright protection and contains no IP that needs protecting post the program code
Sep 17 '08 #2

Expert Mod 5K+
P: 8,916
P.S. A quick look round the net suggests you may be getting a segmentation fault SIGSEGV.

This is typically (but not always) cause by an invalid memory access. An invalid memory access is typically (but not always) caused by dereferencing a pointer that is not valid (NULL or has had its memory freed) or by an out of bounds array access.
Sep 17 '08 #3

Expert 10K+
P: 11,448
Is the last statement of your main() function a "return 0" or an "exit(0)"?

kind regards,

Sep 17 '08 #4

Expert 100+
P: 2,400
If this error code is generated by a standard library function then perror() will print text explaining what the error means.

You would improve the program if you embedded perror() calls as needed to document all standard library errors:
Expand|Select|Wrap|Line Numbers
  1. #include <errno.h>
  2. #include <stdio.h>
  4. ...
  5. <call to some standard library function>
  6. if (errno != 0) {
  7.    perror("Something helpful");
  8.    exit(errno);
  9.    }
  10. ...
However, if you want to keep your focus on this particular problem then you could simply write a short program to tell you what that error code means. Notice that setting errno to 355 [decimal value] is different than setting it to 0355 [octal value]. I don't know if your error message is reporting a decimal, octal, or hexadecimal value.
Expand|Select|Wrap|Line Numbers
  1. #include <errno.h>
  2. #include <stdio.h>
  4. int main(void) {
  5.    errno = 355;
  6.    perror(NULL);
  7.    return 0;
  8.    }
Sep 17 '08 #5

Expert 100+
P: 849
I checked those errno codes with strerror, none of them were recognized, regardless of base. I agree that this is probably an application-defined error.
Sep 18 '08 #6

P: 2
Hello all,

Thanks for the advice. I figured out the cause of the error. I used # in an inappropriate place and I think the compiler thought they were openmp related.

I've never used the errno.h library so thanks for clueing me into that and the rest of the replies, they were all informative.


Sep 22 '08 #7

Post your reply

Sign in to post your reply or Sign up for a free account.