Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I've seen a lot of examples using dialog tools into scripts with lines as follows:

trap "rm $datafile" 0 1 2 5 15

What I don't understand is the meaning of SIGNAL 5, ok I know is SIGTRAP. But shame on me, still I don't understand its real significance...

Thanks in advance!!

share|improve this question

1 Answer 1

up vote 3 down vote accepted

There's a manpage signal(7):

Signal         Value   Action   Comment
SIGTRAP        5        Core    Trace/breakpoint trap

This signal (as the manpage suggests) is primarily used by debugging tools like gdb or strace, respectively the ptrace(2) system call. If one process is tracing another process's activity through ptrace(2), SIGTRAP will be heavily used to »interrupt« the child, even though the child in most cases won't effectively know this happened (a process monitored through ptrace(2) does not necessarily notice which signal had been sent to it, because of the tracer being able to intercept and filter delivered signals and SIGTRAP primarily serves to inform the tracer that something noticable happened).

Looking at the ptrace(2) manpage is very enlightening in this case.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.