Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting exit code of a terminated process

Tags:

windbg

I'm debugging a process in WinDbg, and the process exited:

0:009> g
(bunch of regs...)
ntdll!NtTerminateProcess+0xc:
770ad43c c20800          ret     8
0:009> g
       ^ No runnable debuggees error in 'g'

At this point, how do I get the process' exit code?

like image 405
Jonathan Avatar asked Sep 23 '14 10:09

Jonathan


People also ask

What is exit code passed by a process when it terminates?

Exit Code 1 indicates that a container shut down, either because of an application failure or because the image pointed to an invalid file. In a Unix/Linux operating system, when an application terminates with Exit Code 1, the operating system ends the process using Signal 7, known as SIGHUP.

Does exit terminate process?

25.7. 1 Normal TerminationThe exit function tells the system that the program is done, which causes it to terminate the process. status is the program's exit status, which becomes part of the process' termination status. This function does not return.

What does exit code 9 mean?

Exit code 9 can be due to the OS killing your process due to being out of memory. Check your system logs to see if that is the case.


1 Answers

You could find it as the second argument of ZwTerminateProcess. NtTerminateProcess is just the kernel version of it, right?

0:000> kb
ChildEBP RetAddr  Args to Child              
003ff414 7774d5ac ffffffff 1234abcd 00000000 ntdll!ZwTerminateProcess+0x12
003ff430 759c79ec 00000000 77e8f3b0 ffffffff ntdll!RtlExitUserProcess+0x85
...

Or the fourth parameter of RtlExitUserProcess

0:000> kn
 # ChildEBP RetAddr  
00 003ff414 7774d5ac ntdll!ZwTerminateProcess+0x12
01 003ff430 759c79ec ntdll!RtlExitUserProcess+0x85
...

0:000> .frame 01
01 003ff430 759c79ec ntdll!RtlExitUserProcess+0x85

0:000> dd esp L4
003ff414  7771fcc2 7774d5ac ffffffff 1234abcd
like image 68
Thomas Weller Avatar answered Oct 11 '22 20:10

Thomas Weller