#include<stdio.h>
#include<stdlib.h>
#include<signal.h>
/*father process send signal to son*/
//下面这个处理函数只执行了第一行,原因不明
void dd(int a,siginfo_t *t,void *v)
{
printf("a=%d,signo=%d,sigcode=%d,send pid=%d,value=%s\n",a,
t->si_signo,t->si_code,
t->si_pid,(char*)(t->si_ptr));
// sleep(2);
printf("receive value from process,the value equal/n");
}
main()
{
//int r;
pid_t r;
r=fork();
if(r!=0)
{
printf("father process\n");
//father process
sleep(2);
union sigval val;
val.sival_ptr="helloworld";
sigqueue(r,59,val);
}else{
//son process
printf("son process\n");
//registe signal deal function
struct sigaction act={};
act.sa_flags=SA_SIGINFO;
act.sa_sigaction=dd;
sigaction(59,&act,0);
sleep(5000);
while(1);
}
}