So I am working on this code for a class and I have little experience with signal handlers. I have 95% of my code done, however, I am struggling with this bit.
This is what the professor is asking for on this assignment.
Then, main() should install 4 signal handler:
The handler for TIME_OVER_SIGNAL announces that the time is up and sets shouldRun to 0.
The handler for WIN_SIGNAL announces that the user won and sets shouldRun to 0.
The handler for CORRECT_SIGNAL announces that the user got their last guess correct.
The handler for INCORRECT_SIGNAL announces that the user got their last guess wrong, and should start again from the beginning.
NOTE: Perhaps you can make the same handler handle both CORRECT_SIGNAL and INCORRECT_SIGNAL.
I haven't been successful finding any examples online similar to this to steer me in the right direction of what to do.
This is what I basically got out of the explanation and I know for a fact it's probably way off the mark... How do I go about installing these so they output a particular message like is being asked? The only examples I can find online are for generic alarms, sigChld, or to be able to Ctrl^C out of a running program.
void timeOverSignalHandler(int sigINT)
{
printf("Oh no! The time is up!");
shouldRun = 0;
}
I'm confused what arguments should be passed. I'm also confused whether or not I should be doing something different within the handler and when I call the handler within the main I should have the output generate there.
If anybody could be kind enough to guide me in the right direction with this one I would greatly appreciate your help! Any sort of example that would be similar to this would be great, where the handler is used to output a specific phrase to the user. Doesn't have to necessarily be these particular handlers that I need to do for the assignment. This is a C program!