23

My C++ application crashes periodically. It writes Terminated in the terminal and stops. I don't have any idea what the reason is (GDB is not solution; it is a multithreaded application, and the error appears on a big amount of threads, only that GDB can not process them, due to its low performance).

What does exit code 143 mean on CentOS Linux? Does it contain information about the reason of the crash?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Vitalii
  • 4,434
  • 4
  • 35
  • 77
  • 1
    Why wouldn't gdb help? It will stop when the crash happens, no matter which thread the crash is in. – Some programmer dude Aug 14 '14 at 09:36
  • 1
    If the Linux kernel killed it, the kernel log (use `dmesg` command) might have some info. – jotik Aug 14 '14 at 09:39
  • You could also use e.g. [Valgrind](http://valgrind.org/) to find pointer problems which can cause crashes. And if you have so many threads that gdb can't copy, you might want to try an lower the number of threads to help find the crash (and besides, having many threads is not always a good idea). – Some programmer dude Aug 14 '14 at 09:48
  • Possible duplicate of [How to lookup the meaning of exit codes for Linux command line utilities?](https://stackoverflow.com/questions/7294056/how-to-lookup-the-meaning-of-exit-codes-for-linux-command-line-utilities) – user7610 Aug 16 '17 at 14:17
  • In order to handle the graceful shutdown of your application you will need to catch the `SIGTERM` signal and trigger the correct shutdown sequence. – Bodo Hugo Barwich Mar 19 '21 at 08:46
  • It's the normal behaviour for applications to exit immediately if they don't have the suiting **Signal Handler** implemented. – Bodo Hugo Barwich Mar 19 '21 at 09:07
  • There are *plenty* of duplicates for this. A starting point is *[Are there any standard exit status codes in Linux?](https://stackoverflow.com/questions/1101957/are-there-any-standard-exit-status-codes-in-linux)* (2009). See also [the linked questions](https://stackoverflow.com/questions/linked/1101957). E.g., from [the highest scored answer](https://stackoverflow.com/questions/1101957/are-there-any-standard-exit-status-codes-in-linux/1535733#1535733), 143 = 128 + 15 = 143 →Fatal error signal "15" (whatever that is) – Peter Mortensen Aug 18 '23 at 16:00

4 Answers4

41

143 usually means the application caught a SIGTERM signal, meaning the process was killed. This could be because another process killed it, or perhaps because the operating system killed it for using too much memory or some other resource, etc. Without more information, it's hard to know.

Austin
  • 2,982
  • 2
  • 28
  • 36
26

There are some exit codes which have either defined or generally agreed upon meaning.

In case of 143, which is 128 + 15, that means program died with signal 15, which is SIGTERM

According to the above table, exit codes 1 - 2, 126 - 165, and 255 have special meanings, and should therefore be avoided for user-specified exit parameters.

See the table at http://www.tldp.org/LDP/abs/html/exitcodes.html

user7610
  • 25,267
  • 15
  • 124
  • 150
4

A shell-faked exit code of the form 128+KillingSignal means the program was killed by some KillingSignal. Killing signal #15 is SIGTERM (Try kill -l 15, kill -l $((143-128)) or even kill -l 143 (kill knows about this shell convention) to get a written description (TERM in this case) of the signal). SIGTERM is the default signal sent by the kill utility if no other signal is specified. It's a basic termination request.

Likely, some user or some application killed it (SIGTERM is a catchable signal—if the kernel were to kill (out of memory condition or a security violation), it wouldn't be so gentle, sending the-always -uncatchable SIGKILL or a special uncatchable SIGSYS). Much less likely, the program killed itself with SIGTERM and much much less likely, in defiance of conventions, the program exited with the actual value 143.

Petr Skocik
  • 58,047
  • 6
  • 95
  • 142
-1

Error 143 means that the application is been killed by some other application or the OS itself. this error is due to many reasons such as performing some unauthorized operation i.e. exploiting user privileges, or the system cannot provide the required drive or directory ,or problem in DNS configuration, or in rare cases inexact float point result..but without sufficient information exact cause is hard to tell...

  • As the others already explained it means that the application has received a **Shutdown Signal**. That does not indicate any error. It is the normal procedure to terminate a process by the operating system or by the parent process. – Bodo Hugo Barwich Mar 19 '21 at 09:10