linux-sysprog · intermediate · ~15 min
Use fork + kill + waitpid to coordinate signal delivery.
Implement int signal_child_to_exit(int seconds) that:
_exit(7). Then pauses.seconds (use usleep for sub-second), then kill(child, SIGUSR1)._exit).Return -1 on any fork/wait failure.
The classic IPC primitive: parent forks a worker, signals it to stop when work is done.
#include <signal.h>
#include <sys/wait.h>
#include <unistd.h>
int signal_child_to_exit(int seconds) {
/* TODO */
return -1;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.