Code:
#include <stdio.h>
#include <signal.h>
#include <unistd.h>
void sig_handler(int signo, siginfo_t *info, void *context);
int main(void);
void sig_handler(int signo, siginfo_t *info, void *context)
{
if(info) {
printf(" SIGNAL (number) : %d\n", info->si_signo);
printf(" SIGNAL (pid ) : %d\n", info->si_pid);
}
}
int main(void)
{
struct sigaction new_action, old_action;
new_action.sa_sigaction = sig_handler;
new_action.sa_flags = SA_SIGINFO;
sigemptyset(&new_action.sa_mask);
if(sigaction(SIGUSR1, &new_action, &old_action) == -1) {
perror(" sigaction");
exit(-1);
}
pause();
return(0);
}
Make sure the structure members of type 'struct sigaction' i've used here are supported in your AIX version too. I've tested the above program in Digital 4.0, and works perfect.
In function sig_handler(), the member info->si_pid is the PID of the process which signalled and info->si_signo is the signal number it signalled.