I need to write wrapper functions for fork and signal functions. These functions will handle errors by fork() and signal() and exit, if an error occurs.
The problem is I am not sure exactly what to check for on either function.
Here is some sample code for both of them. Fork does not work correctly (I'm guessing I may need to use fprintf instead of perror) and I am not sure if I am returning the right thing for signal.
Any help greatly appreciated.
pid_t Fork(void) {
pid_t p;
if ((p=fork())<0) {
perror ("fork error");
exit(12);
}
return p;
}
void (*Signal (int sig, void (*disp) (int))) (int) {
if ((signal(sig, disp))==SIG_ERR) {
perror ("signal error");
exit(13);
}
return (*disp);
}