Jigar Prajapati
Jigar Prajapati

Reputation: 31

When can a running process in Unix receive a SIGTRAP (value 5) signal?

There is a one process called NSM in my code. Which abruptly got a SIGTRAP signal and it got killed. So just wanted to know that when can a process get a SIGTRAP signal?

Upvotes: 3

Views: 4531

Answers (2)

RKou
RKou

Reputation: 5221

Some libraries raise a SIGTRAP upon some critical errors.

For example, in the GLIB, g_thread_join() service which joins a thread, relies on pthread_join() from the underlying PTHREAD library. In order to prevent deadlocks, the latter checks if two threads try to join with each other or the current thread tries to join itself. If either case occurs, the EDEADLK errno is returned to the caller. On such error, the calling GLIB raises a SIGTRAP signal. Hence, if a debugger is attached to the running process, this permits to debug the issue.

Upvotes: 0

incompetent
incompetent

Reputation: 1822

As said in the comments, it is a signal so can be triggered at any time. SIGTRAP signal is handled by the debugger; in the absence of a debugger it is quite natural for the process to be terminated. If you are using static libraries in your project then you are not linking them appropriately. Without further information in your question, I suggest you to check your linking with libraries.

Upvotes: 2

Related Questions