I am attempting to create a non-responsive program handler to signal if a call is taking more than 1 second to respond. The abstraction will send a SIGUSR1 to the caller and will continue to wait. Below is snippets of code but I do not know how to make the process wait 1 second after a call doesn't respond for 1 second.This is a single process, with 1 thread. Using POSIX, any methods are available.
void USR1_handler(){
printf("Call delayed...waiting...");
}
int foo()
{
msg[0] = code_foo;
write(sd, msg, 1);
while (no_message_on_descriptor(sd))
kill(getpid(), SIGUSR1);
read(sd, msg, sizeof(msg));
...
}
int no_message_on_descriptor(int d)
{
/*need help here */
signal(SIGUSR1, USR1_handler);
return(1);
}