Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the exit code of a C# program that throws an exception out of main?

Tags:

c#

In a C# program, what is the exit code defined to be when an exception in thrown out of main? I know you can set the exit code in a number of ways as documented in this excellent answer. But I'm very surprised that I can't find documentation for what the value of the exit code is defined to be when an exception is thrown out of main. Is there a standard that defines what the value of the exit code will be in this case, or does it depend upon the operating system (or chance, or anything else)?

like image 554
Mark Meuer Avatar asked Apr 03 '17 22:04

Mark Meuer


People also ask

What is normal exit code?

An exit code, or sometimes known as a return code, is the code returned to a parent process by an executable. On POSIX systems the standard exit code is 0 for success and any number from 1 to 255 for anything else. Exit codes can be interpreted by machine scripts to adapt in the event of successes of failures.

What is exit code 11 in C?

What the Problem Means. The short answer is that the program did not return a zero as its exit or return code. Waf reports this back in red since it usually means that the program has failed in some way.

How do you exit AC program?

The exit() function is used to terminate program execution and to return to the operating system. The return code "0" exits a program without any error message, but other codes indicate that the system can handle the error messages. Syntax: void exit(int return_code);

Is there an exit function in C?

C library function - exit()The C library function void exit(int status) terminates the calling process immediately. Any open file descriptors belonging to the process are closed and any children of the process are inherited by process 1, init, and the process parent is sent a SIGCHLD signal.


1 Answers

I observe -532462766

PS C:\Projects\Throw\Throw\bin\Debug> .\Throw.exe

Unhandled Exception: System.Exception: Exception of type 'System.Exception' was thrown at Throw.Program.Main(String[] args) in c:\Projects\Throw\Throw\Program.cs:line 13

PS C:\Projects\Throw\Throw\bin\Debug> $LASTEXITCODE
-532462766
like image 132
Jeffrey Rennie Avatar answered Nov 15 '22 07:11

Jeffrey Rennie