q1 Describe how to use sigaction such that a process receivi

q1. Describe how to use sigaction such that a process receiving a signal can know the pid of the originating process of this signal.

q2. Describe how to use sigaction such that a process can send a payload with the signal that can be retrieved by the receiving process.

Solution

q1: use sagaction() system call for signal handler and it takes three parameters such as int (for knowing the signal id or number :ranging from 1 to 31),, siginfo_t*( this parameter is having information like pid of the sender and ucontext_t* ( related to activity of threads like out of many threads which one got the signal.

q2: int sigqueue having parameters (pid_t Pid , int Sig, const union sigval val) , this function sigqueue sends a signal in sig to the given process id and the value parameter is used for data to send.

the value item can be a integer or a pointer so:

union signal_val

{

int signal_val;

void *signal_val1;

};

the receiving process should install a handler using SA_SIGINFO flag to sigaction, then the data can be obtained .

q1. Describe how to use sigaction such that a process receiving a signal can know the pid of the originating process of this signal. q2. Describe how to use sig

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site