Help with sigaction() and sigcontext

Ask a Question related to Mac Programming, Design and Development.

  1. #1

    Default Re: Help with sigaction() and sigcontext

    In article <tobiaspatton-55FDA8.10451930082003@shawnews.vc.shawcable.net>,
    Tobias Patton <tobiaspatton@NOSPAM.shaw.ca> wrote:
    > I'm trying to install a signal handler that will dump a stack crawl.
    Why?

    meeroh

    --
    If this message helped you, consider buying an item
    from my wish list: <http://web.meeroh.org/wishlist>

    Miro Jurisic Guest

  2. Similar Questions and Discussions

    1. sigaction.sa_handler = MyClass::memberFunction;
      In article <3F1D5FBC.3080201@telus.net>, shea martin <samworks@telus.net> wrote: It needs to be a static member, because the signalling...
  3. #2

    Default Re: Help with sigaction() and sigcontext

    In article
    <tobiaspatton-55FDA8.10451930082003@shawnews.vc.shawcable.net>,
    Tobias Patton <tobiaspatton@NOSPAM.shaw.ca> wrote:
    > From reading the manpage for sigaction() and the comments in signal.h, I
    > thought I could use the sigcontext pointer that's passed to the signal
    > handler to get a pointer to my process's stack.
    Yep.
    > One of the fields in
    > this struct is `sc_sp' which I thought was the stack pointer for the
    > user-space process that caused the signal. So I wrote some test code to
    > examine this value. A typical value for `sc_sp' is 0xfb4b7f0, which
    > doesn't look like its in my process's memory space. Sure enough,
    > attempting to dererefence this pointer to walk up the stack results in a
    > segmentation fault.
    Yeah, that doesn't look like a valid stack address.
    > I've included the test code I wrote, and some sample output. The code
    > was compiled using ProjectBuilder 2.1. Any help is appreciated.
    Which version of the OS is this? SA_SIGINFO signal handlers didn't work
    correctly until 10.2.
    > #include <iomanip>
    > #include <iostream>
    > #include <signal.h>
    >
    > void SigActionHandler( int sigNum, siginfo_t* sigInfo, void* sigCtx )
    > {
    > ( void ) sigInfo;
    >
    > struct sigcontext* ctx = ( sigcontext* ) sigCtx;
    >
    > std::cout << "Signum : " << sigNum << std::endl
    It's not safe to use STL from a signal handler. See
    <http://www.opengroup.org/onlinepubs/007908799/xsh/sigaction.html> for a
    list of functions that are async-signal safe.

    -Eric

    --
    Eric Albert [email]ejalbert@stanford.edu[/email]
    [url]http://rescomp.stanford.edu/~ejalbert/[/url]
    Eric Albert Guest

Posting Permissions

  • You may not post new threads
  • You may 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