Questions tagged [exit-code]

An exit code is signaled by a program on termination to indicate if it completed successfully, or, if it did not, what sort of failure condition occurred.

1070 questions
969
votes
7 answers

How do I get the application exit code from a Windows command line?

I am running a program and want to see what its return code is (since it returns different codes based on different errors). I know in Bash I can do this by running echo $? What do I do when using cmd.exe on Windows?
Skrud
  • 11,604
  • 5
  • 24
  • 22
930
votes
9 answers

In a Bash script, how can I exit the entire script if a certain condition occurs?

I'm writing a script in Bash to test some code. However, it seems silly to run the tests if compiling the code fails in the first place, in which case I'll just abort the tests. Is there a way I can do this without wrapping the entire script inside…
samoz
  • 56,849
  • 55
  • 141
  • 195
583
votes
13 answers

How to check the exit status using an 'if' statement

What would be the best way to check the exit status in an if statement in order to echo a specific output? I'm thinking of it being: if [ $? -eq 1 ] then echo "blah blah blah" fi The issue I am also having is that the exit statement is before…
deadcell4
  • 6,085
  • 3
  • 14
  • 10
558
votes
14 answers

How do I specify the exit code of a console application in .NET?

I have a trivial console application in .NET. It's just a test part of a larger application. I'd like to specify the "exit code" of my console application. How do I do this?
MrDatabase
  • 43,245
  • 41
  • 111
  • 153
376
votes
12 answers

Are there any standard exit status codes in Linux?

A process is considered to have completed correctly in Linux if its exit status was 0. I've seen that segmentation faults often result in an exit status of 11, though I don't know if this is simply the convention where I work (the applications that…
Nathan Fellman
  • 122,701
  • 101
  • 260
  • 319
322
votes
16 answers

Exit codes in Python

I got a message saying script xyz.py returned exit code 0. What does this mean? What do the exit codes in Python mean? How many are there? Which ones are important?
sundeep
  • 4,048
  • 7
  • 25
  • 22
236
votes
5 answers

Difference between exit(0) and exit(1) in Python

What's the difference between exit(0) and exit(1) in Python? I tried looking around but didn't find a specific question on these lines. If it's already been answered, a link would be sufficient.
seeker
  • 6,841
  • 24
  • 64
  • 100
122
votes
7 answers

ruby system command check exit code

I have a bunch of system calls in ruby such as the following and I want to check their exit codes simultaneously so that my script exits out if that command fails. system("VBoxManage createvm --name test1") system("ruby test.rb") I want something…
user1530318
  • 25,507
  • 15
  • 37
  • 48
117
votes
3 answers

What is a thread exit code?

What exactly is a thread exit code in the Output window while debugging? What information it gives me? Is it somehow useful or just an internal stuff which should not bother me? The thread 0x552c has exited with code 259 (0x103). The thread 0x4440…
Ondrej Janacek
  • 12,486
  • 14
  • 59
  • 93
81
votes
4 answers

What are the error exit values for diff?

On the diff man-page I've found these exit values: 0 No differences were found. 1 Differences were found. >1 An error occurred. Are there different exit values above 1 for different errors?
sid_com
  • 24,137
  • 26
  • 96
  • 187
78
votes
5 answers

Why are my PowerShell exit codes always "0"?

I've got a PowerShell script as follows ##teamcity[progressMessage 'Beginning build'] # If the build computer is not running the appropriate version of .NET, then the build will not run. Throw an error immediately. if( (ls…
Chase Florell
  • 46,378
  • 57
  • 186
  • 376
72
votes
5 answers

Exit code of variable assignment to command substitution in Bash

I am confused about what error code the command will return when executing a variable assignment plainly and with command substitution: a=$(false); echo $? It outputs 1, which let me think that variable assignment doesn't sweep or produce new error…
Reorx
  • 2,801
  • 2
  • 24
  • 29
71
votes
13 answers

Return value from thread

How do I get a thread to return a tuple or any value of my choice back to the parent in Python?
pjay
  • 2,422
  • 4
  • 21
  • 20
68
votes
4 answers

How to trap exit code in Bash script

There're many exit points in my bash code. I need to do some clean up work on exit, so I used trap to add a callback for exit like this: trap "mycleanup" EXIT The problem is there're different exit codes, I need to do corresponding cleanup works.…
Dagang
  • 24,586
  • 26
  • 88
  • 133
65
votes
6 answers

check if command was successful in a batch file

How within a batch file to check if command start "" javaw -jar %~p0/example.jar was successful or produced an error? I want to use if/else statements to echo this info out.
31415926
  • 3,811
  • 7
  • 47
  • 78
1
2 3
71 72