Newlib raise() - multiple definitions?
Posted: Sat Sep 22, 2007 4:25 am
I've ported newlib, and was having trouble working out exactly how I was supposed to find out what function a user had registered as a signal handler. As far as I could see, raise() (send signal to the current process) mapped immediately through to kill(getpid(), sig), and there were no macros to get signal functions etc (sigaction isn't implemented in newlib).
So anyway, I decided to write a small test program:
I ran it, and lo and behold it worked perfectly! Putting trace code into my kill() function (which was a stub) showed it wasn't being called at all - strange.
I then did a grep -r "_raise_r" ./libc/ in case I was missing something. I was. There is a *second* definition of raise(), in signal.c. This one calls a locally defined handler if one exists.
So, my question is - does anyone know why there are two definitions of the same function in two different files in the same directory: raise.c and signal.c ??
It seems strange.
Cheers,
JamesM
So anyway, I decided to write a small test program:
Code: Select all
void func(int sig)
{
printf("Recieved signal: %d\n", sig);
}
... in main
signal(10, &func);
raise(10);
I then did a grep -r "_raise_r" ./libc/ in case I was missing something. I was. There is a *second* definition of raise(), in signal.c. This one calls a locally defined handler if one exists.
So, my question is - does anyone know why there are two definitions of the same function in two different files in the same directory: raise.c and signal.c ??
It seems strange.
Cheers,
JamesM