Professional Web Applications Themes

signal hendlers - UNIX Programming

Hello I need use in signal handler function some data structure, but I dont know how. I have something like this: #ifdef SA_SIGINFO act.sa_flags |= SA_SIGINFO; #endif in my Signal() implementation ; it gives me that signal handler function have 2 new parameters First is siginfo_t structure pointer but i dont know what type is secound ? void sig_chld(int sig, struct siginfo_t *x, ???) Next problem is how to copy or point data structure , which i want to give my signal handler function, a dont know how the siginfo_t structure looks like? Resoult should be like that: void sig_chld(int ...

  1. #1

    Default signal hendlers

    Hello

    I need use in signal handler function some data structure, but I dont know
    how.
    I have something like this:

    #ifdef SA_SIGINFO
    act.sa_flags |= SA_SIGINFO;
    #endif
    in my Signal() implementation ; it gives me that signal handler function
    have 2 new parameters
    First is siginfo_t structure pointer but i dont know what type is secound ?

    void sig_chld(int sig, struct siginfo_t *x, ???)

    Next problem is how to copy or point data structure , which i want to give
    my signal handler function,
    a dont know how the siginfo_t structure looks like?


    Resoult should be like that:

    void sig_chld(int sig, struct siginfo_t *x, ???);
    Signal(SIGCHLD,sig_chld,my_data_structure);

    And x should point to my data?

    Thanks Wojtek


    Wojciech Guest

  2. #2

    Default Re: signal hendlers

    "Wojciech Potyka" <com> writes:
     
     

    Generally, you can't; even though the 3rd argument is a
    void * it's really a process context which contains the
    state at the time the signal occured.

    Casper
    --
    Expressed in this posting are my opinions. They are in no way related
    to opinions held by my employer, Sun Microsystems.
    Statements on Sun products included here are not gospel and may
    be fiction rather than truth.
    Casper Guest

  3. #3

    Default Re: signal hendlers

    On Sun, 28 Dec 2003 22:11:37 +0100, "Wojciech Potyka"
    <com> wrote:
     

    As pointed out by Casper Dik, you can't do this. However, it's
    possible that you may be able to do something like what you want using
    real-time signals (supported on most modern Unix implementations):

    1. Esatablish the handler using SA_SIGINFO, setting the sa_sigaction
    field to point to your handler.

    2. Send the (real-time) signal using siqqueue(pid, sig, value). The
    'value' argument is a union which may contain either an integer or a
    pointer which is included in the siginfo_t structure passed to the
    signal handler.

    3. The signal handler can look at the data sent with sigqueue using
    the si_value.sival_int or si_value.sival_ptr fields.

    Cheers,

    Michael
    Michael Guest

Similar Threads

  1. Signal Handling
    By Eric in forum AIX
    Replies: 3
    Last Post: December 4th, 09:01 PM
  2. signal problem
    By C&J in forum PERL Miscellaneous
    Replies: 1
    Last Post: August 5th, 06:48 AM
  3. signal
    By DL in forum UNIX Programming
    Replies: 0
    Last Post: July 11th, 02:05 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139