Fletcher> Not exactly. According to the man page for sigaction, you
Fletcher> can pick which function prototype will be used with the
Fletcher> SA_SIGINFO flag.
SA_SIGINFO isn't part of POSIX as far as I know, but is an extension
(it's in the Single Unix spec, but not all that widely portable yet).
Fletcher> If the flag is reset, you use void(*sa_hanlder)().
No, that should be void (*sa_handler)(int).
Of course, some systems may define it as void (*sa_handler)() in the C
sense (i.e. "pointer to function taking unspecified arguments" rather
than "pointer to function taking no arguments") for convenience; one
should, however, always be able to supply a function that takes a
single int parameter.
--
Andrew.
comp.unix.programmer FAQ: see <URL: http://www.erlenstar.demon.co.uk/unix/>
or <URL: http://www.whitefang.com/unix/>
>>>>>> "Ryan" == Ryan <xant...@geocities.com> writes:
>
> Ryan> I tried to use sigaction(), but now I'm noticing sigaction()
> Ryan> implements the signal handling function as a void (*func)(),
> Ryan> with no parameters,
>
>This is not correct. The type of signal handler used by sigaction()
>should be void (*)(int). The signal number is passed to the function
>in exactly the same way as for signal().
>
>--
>Andrew.
Thanks for the tip.
As it turns out, the man page for sigaction on my AIX machine states:
"the sigaction structure has the following fields:
void (*sa_handler)();
sigset_t sa_mask;
int sa_flags;"
However, with your input I decided to challenge the man page, and sure
enough, when I compile the code with the -E option (preprocessor
output only), it shows that it is using the void (*sa_handler)(int)
version of the function in that structure after all.
Now I've got it figured out and working. Thanks to everyone for the
input.
---------------------------------------
Remove nospam info if you must reply via e-mail.
> Now I have a problem. I'm trying to implement a function that
>will be a generic signal handling function for an application, one
>that will execute different code depending on the signal that was
>caught. I tried to use sigaction(), but now I'm noticing sigaction()
>implements the signal handling function as a void (*func)(), with no
>parameters, whereas signal() used a void (*func)(int), with the int
You sure thats not an old style prototype for the handler.
On my linux box I have
typedef void (*__sighandler_t)(int);
...
struct sigaction
{
sighandler_t ...
};
Steve
> Fletcher> Not exactly. According to the man page for sigaction, you
> Fletcher> can pick which function prototype will be used with the
> Fletcher> SA_SIGINFO flag.
>SA_SIGINFO isn't part of POSIX as far as I know, but is an extension
>(it's in the Single Unix spec, but not all that widely portable yet).
It *is* in the current POSIX standard (POSIX.1-1996), but you're right
about the portability: I don't think many systems have updated from the
old standard (POSIX.1-1990) to the current one yet.
--
Geoff Clare g...@unisoft.com
UniSoft Limited, London, England. g...@root.co.uk