Question using signals in my own shell..

Wasn't really sure where to put this, since I'm using C in UNIX, but I am making my own shell... so, what's going on is this:

For our program, we had to create our own shell, and if the user pressed ctrl-c just at the cmdline, then this signal would be ignored, but if there is a foreground process running, let's say, "sleep 10", and ctrl-c was pressed, then this process would be terminated... however, my problem lies within background processes... when I press ctrl-c after running something like "sleep 10 &", where the '&' indicates it's a background process, it uses the correct if branch of my SIGINT_handler, but it terminates the process.... so it's definitely something wrong with either the handler, or the installation of the signal.

What I don't get is... if the ctrl-c at the command line doesn't quit the program, why would it terminate my background process? Is it because the parent process just puts the ctrl-c onto the child processes? If so, is there a way to add something to my SIGINT_handler to make it ignore this signal?

****Let me just say that I have successfully been able to ignore the signal for a background process, but this way doesn't use my SIGINT_handler, which I do want it to use so some text gets printed. The way I'm talking of is just using "signal(SIGINT, SIG_IGN)", but like I said, doesn't use my SIGINT_handler...

This is my SIGINT_handler:

void SIGINT_handler(int sig)
{
if (foreground_pid == 0)
{
fprintf(stderr, "\nSIGINT ignored\n");
}
else
{
kill(foreground_pid, SIGINT);
foreground_pid = 0;
}
}

And then when I install the handler/signal, I use signal(SIGINT, SIGINT_handler) and also set foreground_pid in its respective spot... so if anyone can help, that'd be awesome, and if you need to see more code or some things are unclear, ask. Thanks.

I don't understand why it doesn't work..