I have a pcap_loop function in another function, that captures packets until the user stops it, i.e.
void functionA() { signal(SIGINT, terminate_process);
You can use alarm to generate a signal after a given number of seconds:
void functionA() { signal(SIGALRM, terminate_process); alarm(100); }