473,388 Members | 1,209 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

Interpreting exit error code

Hello,

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
or
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.

Mike
Sep 17 '08 #1
6 2663
Banfa
9,065 Expert Mod 8TB
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.

Try:
  • 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
Banfa
9,065 Expert Mod 8TB
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
JosAH
11,448 Expert 8TB
Is the last statement of your main() function a "return 0" or an "exit(0)"?

kind regards,

Jos
Sep 17 '08 #4
donbock
2,426 Expert 2GB
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>
  3.  
  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>
  3.  
  4. int main(void) {
  5.    errno = 355;
  6.    perror(NULL);
  7.    return 0;
  8.    }
Cheers,
donbock
Sep 17 '08 #5
Laharl
849 Expert 512MB
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
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.

Sincerely,

Mike
Sep 22 '08 #7

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

Similar topics

10
by: r6uji7 | last post by:
hello, i am new to PHP programming and wondered if u could help. lets say i have the following files: 1. error.php: that is routed to for all errors. this page should display proper and...
12
by: Ivan Voras | last post by:
In a code such as: if len(sys.argv) < 2: print "I need arguments!" sys.exit(1) Is sys.exit() really a good choice? Is there something more elegant? (I tried return but it is valid only in a...
1
by: Guinness Mann | last post by:
Pardon me if this is not the optimum newsgroup for this post, but it's the only .NET newsgroup I read and I'm certain someone here can help me. I have a C# program that checks for an error...
32
by: Protoman | last post by:
I have a function that calculates the mean of the some numbers; I need it to accept any number of parameters (one needs to be the number of the other parameters) Can you help me out here? Here's...
2
by: GGerard | last post by:
Hello Is there a way to exit all running procedures with one command? Sometimes a procedure(1) will call another procedure(2) which could call a third procedure(3) and what I would like to...
8
by: Atanas Banov | last post by:
i ran onto this weirdness today: seems like close() on popen-ed (pseudo)file fails miserably with exception instead of returning exit code, when said exit code is -1. here is the simplest...
3
by: GinTon | last post by:
Is the same use _sys.stderr.write('error message'); sys.exit(1)_ than _sys.exit('error message')_ ? Note: help(sys.exit) If the status is omitted or None, it defaults to zero (i.e., success)....
11
by: yawnmoth | last post by:
To quote from <http://php.net/function.include>, "Because include() is a special language construct, parentheses are not needed around its argument. Take care when comparing return value." ...
0
by: Gary Robinson | last post by:
In Python 2.5.2, I notice that, in the interpreter or in a script, I can exit with: exit() But I don't see exit() mentioned as a built-in function; rather the Python Library Reference says we...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.