struct sigaction psa;
I have enabled my signal handler in the main function as shown below:
memset (&psa, 0, sizeof (psa)
#include <stdio.h>
#include <signal.h>
static void pSigHandler(int signo){
switch (signo) {
case SIGTSTP:
printf("TSTP");
fflush(stdout);
break;
}
}
int main(void)
{
struct sigaction psa;
psa.sa_handler = pSigHandler;
sigaction(SIGTSTP, &psa, NULL);
for(;;) {}
return 0;
}
Because you need to fflush(stdout)
try with C-z
I'm not even sure if it's safe to use stdio in a signal handler though.
Update: http://bytes.com/topic/c/answers/440109-signal-handler-sigsegv
According to that link, you should not do this.