I'm trying to send the child process a blank(SIGUSR1) signal from the parent. As far as I know, I have the signal set up properly. I feel like I am messing up on the Kill() function call. I expect some sort of printed output, but I get nothing. Not from inside the child nor from the signal function itself.
code:
void my_handler(int signum);
int main()
{
pid_t pid;
if((pid = fork()) == -1)
{
printf("Error on fork().\n");
exit(1);
}
if(pid == 0)
{
if(signal(SIGUSR1, my_handler))
{
printf("+1");
}
}
else if(pid > 0)
{
sleep(2);
kill(pid, SIGUSR1);
}
}
void my_handler(int signum)
{
if (signum == SIGUSR1)
{
printf("Received SIGUSR1!\n");
}
}