Professional Web Applications Themes

signal call failing on 10.1? - Mac Programming

Argh! There is one thing stopping me from releasing the latest version of my shareware: it doesn't work on 10.1. I've narrowed it down to exactly this line: signal(SIGCHLD, fireman); The line before this one is executed, but the line after is not. The application dies straightaway. The really funky (s/n/c/) thing is that I've got another test application which looks like this: int main(int argc, char* argv[]) { printf("Hello\n"); signal(SIGCHLD, signalCatch); daemon(0, 0); switch(fork()) { case 0: syslog(LOG_INFO, "Child1"); exit(EXIT_SUCCESS); default: syslog(LOG_INFO, "Parent"); for(;;); } return 0; } void signalCatch(int para) { syslog(LOG_INFO, "Caught"); } Which works exactly as ...

  1. #1

    Default signal call failing on 10.1?

    Argh! There is one thing stopping me from releasing the latest version
    of my shareware: it doesn't work on 10.1.

    I've narrowed it down to exactly this line:

    signal(SIGCHLD, fireman);

    The line before this one is executed, but the line after is not. The
    application dies straightaway. The really funky (s/n/c/) thing is that
    I've got another test application which looks like this:

    int main(int argc, char* argv[])
    {
    printf("Hello\n");
    signal(SIGCHLD, signalCatch);
    daemon(0, 0);
    switch(fork())
    {
    case 0:
    syslog(LOG_INFO, "Child1");
    exit(EXIT_SUCCESS);

    default:
    syslog(LOG_INFO, "Parent");
    for(;;);
    }
    return 0;
    }

    void signalCatch(int para)
    {
    syslog(LOG_INFO, "Caught");
    }

    Which works exactly as you would expect on 10.1 and 10.2. The start of
    my real application looks like this:

    int main(int argc, char* argv[])
    {
    int clientSocket;
    char *authStr;
    JSFunction *compiledPAC;

    if(argc != 7)
    {
    syslog(LOG_ERR, "Fatal Error: authoxyd needs 6 command line
    parameters. Check there are no spaces in your settings.");
    return 1;
    }

    syslog(LOG_ERR, "One.");
    signal(SIGCHLD, fireman);
    syslog(LOG_ERR, "Two.");
    daemon(0, 0);
    syslog(LOG_ERR, "Three.");

    ....

    void fireman(int sig)
    {
    while (waitpid(-1, NULL, WNOHANG) > 0)
    ;
    }

    But "Two." is never written to the system log! I've tried changing the
    order of statements, changing the signiture of the signal handler,
    making sacrifices, and still no luck. Why on earth would one of these
    programs work and the other not? My real program is started by a
    preference pane with a system() call which passes various arguments, but
    it doesn't appear to matter if I call it manually from the command line.

    I don't have the developer tools installed on my 10.1 install, which may
    or may not be relevant. I know it makes it very hard to debug!

    Has anyone got the slightest of clues? I'm really unsure where to go
    from here! The only thing I can think of that has changed between when
    this did work is perhaps my library linking. My app now links to the
    static libdl library (as well as libcurl and libjs) but I can't imagine
    why this would matter. signal is part of the standard c library (libc)
    which should be dynamically linked as normal, right?

    --
    Heath
    __________________________________________________ ______
    | *Nothing is foolproof to a sufficiently talented fool* |
    | _\|/_ |
    |________________________________________m(. .)m_________|
    Heath Guest

  2. #2

    Default Re: signal call failing on 10.1?

    In article <newcastle.edu.au>,
    Heath Raftery <com> wrote:
     

    I'm a bit surprised that you care about 10.1 support. :) If someone
    won't pay the money for either of two upgrades that'll greatly improve
    their system (10.2 or 10.3), I can't imagine they'll be paying for much
    shareware.

    -Eric

    --
    Eric Albert edu
    http://rescomp.stanford.edu/~ejalbert/
    Eric Guest

  3. #3

    Default Re: signal call failing on 10.1?

    In article <newcastle.edu.au>,
    Heath Raftery <com> wrote:
     

    [snip]
     

    [snip]
     

    Well, then, install them, and run the program under GDB. Set a breakpoint on
    exit(), and you will either die on a signal (in which case GDB will tell you
    which signal) or you will hit the exit() breakpoint.

    meeroh

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

    Miro Guest

  4. #4

    Default Re: signal call failing on 10.1?

    Miro Jurisic <org> wrote: [/ref]
     

    Hate to be painful... but how do I set that breakpoint on exit()? Obviously,
    exit() is not part of my source... Still, good hint. I guess I might have to
    take the plunge. I was actually hoping to have a clean install of 10.1
    precisely for testing purposes - not everyone has the developer tools
    installed. I'll let you know what the signal is (don't suppose that is
    possible to find without the Dev Tools?).

    --
    *--------------------------------------------------------*
    | ^Nothing is foolproof to a sufficiently talented fool^ |
    | Heath Raftery, HRSoftWorks _\|/_ |
    *______________________________________m_('.')_m__ _______*
    Heath Guest

  5. #5

    Default Re: signal call failing on 10.1?

    Eric Albert <edu> wrote: 
     [/ref]
     

    With each release, my compassion is strained! Still, I know I have users on
    10.1 (or at least, at last release I did) and I'd hate to alienate them. It
    is becoming a fair amount of work to support 10.1. Older libraries, and
    missing functionality...
     

    Well... my shareware is very cheap, and more of a helping hand than a fortune
    making enterprise!

    --
    *--------------------------------------------------------*
    | ^Nothing is foolproof to a sufficiently talented fool^ |
    | Heath Raftery, HRSoftWorks _\|/_ |
    *______________________________________m_('.')_m__ _______*
    Heath Guest

  6. #6

    Default Re: signal call failing on 10.1?

    In article <bmfgoq$q79$newcastle.edu.au>,
    Heath Raftery <com> wrote:
     

    In gdb, type "b exit". Yes, it's a valid request to have a clean install of 10.1
    for this purpose, but when you have to debug, you have to debug. If you prefer,
    keep two disks/partitions/disk images around and only go to the one with dev
    tools when you have to.

    hth

    meeroh

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

    Miro Guest

  7. #7

    Default Re: signal call failing on 10.1?

    In article <mit.edu>,
    Miro Jurisic <org> wrote: 

    After rather little thought, I realised of course, that I have gdb
    installed on another harddrive, which is mounted while I'm in 10.1
    anyway. It took a little chroot'ing, but I was able to run gdb without
    installing the Dev Tools for 10.1. Nonetheless, I actually found the
    reason for the exit with gdb. Here's what appeared at the Terminal when
    I launched my application by hand, with the signal() call before the
    daemon() call:

    myApp undefined reference to ___fegetfltrounds expected to be defined in
    /usr/lib/libSystem.B.dylib
    myApp undefined reference to _getnameinfo expected to be defined in
    /usr/lib/libSystem.B.dylib
    myApp undefined reference to _gmtime_r expected to be defined in
    /usr/lib/libSystem.B.dylib
    myApp undefined reference to _localtime_r expected to be defined in
    /usr/lib/libSystem.B.dylib
    myApp undefined reference to _strlcat expected to be defined in
    /usr/lib/libSystem.B.dylib

    Well there it is. Somehow linking against a different libSystem in 10.2
    is now causing problems in 10.1. I imagine (although am not certain)
    that it has something to do with the way I am handling lib linking for
    the curl library. Any ideas?

    --
    Heath
    __________________________________________________ ______
    | *Nothing is foolproof to a sufficiently talented fool* |
    | _\|/_ |
    |________________________________________m(. .)m_________|
    Heath Guest

Similar Threads

  1. Flash failing in dynamic call, settings wrong?
    By Jefferis NoSpamme in forum Coldfusion Server Administration
    Replies: 2
    Last Post: September 29th, 08:10 PM
  2. [7.4.1] signal 11 while accesing DB
    By Marcin in forum PostgreSQL / PGSQL
    Replies: 3
    Last Post: January 24th, 07:48 PM
  3. signal
    By DL in forum UNIX Programming
    Replies: 0
    Last Post: July 11th, 02:05 AM
  4. remote call procedure call failed
    By Dave Warwick in forum Windows Networking
    Replies: 0
    Last Post: July 5th, 03:59 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