I am trying to communicate between 2 processes ( parent and child process in linux ) using signals in C programming language.
The first process does some calculation and provides a data. Then, it sends a signal to the second, which is in a suspended state, waiting for a signal to wake up and collect that data shared by the first process using a shared memory.
How to make the second process wait for a certain time or let's say a period of time ?
Within that period, if the first process provides data and sends a signal to the second, everything is OK. Otherwise, if it doesn't receive any signal from the first within that period, it will do another thing.
How can I make the second process respond to that need ?
Which algorithms and signals should I use to implement this ?
Call to sleep until 10 seconds or signal would be:
struct timeval t = {10, 0};
int rc = select(0, NULL, NULL, NULL, &t);
if (rc == 0) {
// timeout
} else if (errno == EINTR) {
// signal
} else {
// some error