Reputation: 79
This code can't be executed. Signal is sent to the function via signal, but the code inside the function is not running.
void my_sigtrap(int sig) {
LOGD("mtf---- why not working ");
}
void test_signal() {//SIGTRAP
signal(SIGTRAP, my_sigtrap);
}
why my_sigtrap function not working?
Upvotes: 0
Views: 106
Reputation: 15775
The function signal()
does not send the signal, but installs your own signal handler so when that signal is received your function will be executed to handle it. The signal is actually sent to the process using the kill()
API (look up the details using man 2 kill
).
Upvotes: 2