sigaction : using "void (*sa_sigaction)(int, siginfo_t *, void *);"

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hpandey
    New Member
    • Apr 2007
    • 1

    sigaction : using "void (*sa_sigaction)(int, siginfo_t *, void *);"

    sigaction : using "void (*sa_sigaction) (int, siginfo_t *, void *);"
    --------------------------------------------------------------------------------

    hello,

    in sigaction manpage it's written :

    sa_sigaction also specifies the action to be associated with signum.
    This function receives the signal number as its first argument, a
    pointer to a siginfo_t as its second argument and a pointer to a ucon-
    text_t (cast to void *) as its third argument.

    so we can pass arguments to the signal handler (throught "void*"), but I
    can't find the way...
    no way to put it anywhere...

    example :

    void ping(int sig, siginfo_t *siginf, void *ptr)
    {
    ....
    }

    int main()
    {
    struct sigaction sa_ping;
    int foo;

    foo = 3;

    sa_ping.sa_siga ction = ping;
    sigemptyset(&sa _ping.sa_mask);
    sa_ping.sa_flag s = 0;
    sigaction(SIGUS R1, &sa_ping, 0);
    ....
    }

    where I can pass foo value in argument in ping (with a cast in (int *) )???


    if someone has an idea, I'll be thankfull

    Harish
  • horace1
    Recognized Expert Top Contributor
    • Nov 2006
    • 1510

    #2
    have a look at the opengroup documentation on sigaction()
    http://www.opengroup.o rg/onlinepubs/009695399/functions/sigaction.html

    It shows an example which may help

    Comment

    Working...