tags:

views:

236

answers:

3

What are the scenarios where a process gets a SIGABRT in C++? Does this signal always come from within the process or can this signal be sent from one process to another?

Is there a way to identify which process is sending this signal?

+4  A: 

You can send any signal to any process using the kill(2) interface:

kill -SIGABRT 30823

30823 was a dash process I started, so I could easily find the process I wanted to kill.

$ /bin/dash
$ Aborted

The Aborted output is apparently how dash reports a SIGABRT.

It can be sent directly to any process using kill(2), or a process can send the signal to itself via assert(3), abort(3), or raise(3).

sarnold
+4  A: 

abort() sends the calling process the SIGABRT signal, this is how abort() basically works.

abort() is usually called by library functions which detect an internal error or some seriously broken constraint. For example malloc() will call abort() if its interal structures are damaged by a heap overflow.

Luther Blissett
+3  A: 

SIGABRT is commonly used by libc and other libraries to abort the progamm in case of critical errors. For example, glibc sends an SIGABRT in case of a detected double-free or other heap corruptions.

Also, most "assert" implementaions make use of SIGABRT in case of a failed assert.

Furthermore, SIGABRT can be send from any other process like any other signal. Of course, the sending process needs to run as same user or root.

IanH