Why I could not catch the signals on HP_UX? - HP UX

This is a discussion on Why I could not catch the signals on HP_UX? - HP UX ; Hi HP_UX gurus, Here is my enviroment: HOST MACHINE and OPERATING SYSTEM: HPUX 9000, CPU: B2600, build on HP_UX11.20, tested on HP_UX11i COMPILER NAME AND VERSION (AND PATCHLEVEL): config-hpux-11.00.h platform_hpux_gcc.GNU I have a CORBA server which has one main thread ...

+ Reply to Thread
Results 1 to 12 of 12

Thread: Why I could not catch the signals on HP_UX?

  1. Why I could not catch the signals on HP_UX?

    Hi HP_UX gurus,

    Here is my enviroment:

    HOST MACHINE and OPERATING SYSTEM:
    HPUX 9000, CPU: B2600, build on HP_UX11.20, tested on HP_UX11i
    COMPILER NAME AND VERSION (AND PATCHLEVEL):
    config-hpux-11.00.h
    platform_hpux_gcc.GNU


    I have a CORBA server which has one main thread and two private
    threads. The two privates threads are spawned internaly, Private thread
    1 is for monitoring other processes in the system, the private thread 2
    is for processing events from a event queue. In thread 2, the server
    makes a callback to a client using the object that the client
    registered with the server.

    When the client is terminated abnormally before the server makes the
    callback, the object that the server uses to make callback is invalid.
    As a result, sometimes the server gets an unknown exception (I catch it
    with catch(...)), othertimes, the server just hang there at where it
    makes the callback, then the server is terminated. I have added all the
    possible signals in my signal handler, but I did not catch anything,
    except once: I got SIGABRT over the 100 times I tried.

    Question: why did not I catch any signal? I did not find core dump
    either. There must be a signal sent to the process to cause it to be
    terminated, correct? If so, how do I catch it? Is there any other way
    to cause a process to die?

    Any suggestions?

    Thanks
    Sandy


  2. Re: Why I could not catch the signals on HP_UX?

    Sandy wrote:
    > Hi HP_UX gurus,


    > Here is my enviroment:


    > HOST MACHINE and OPERATING SYSTEM:
    > HPUX 9000, CPU: B2600, build on HP_UX11.20, tested on HP_UX11i


    Did you mean to say built on HP-UX 10.20 - IIRC HP-UX 11.20 was only
    for Merced (Itanium1) systems.

    Being built on 10.20 means "green" or "user space" threads - however
    many threads you spawn, there is only one kernel scheduled entity for
    them. Not really "desirable" in this day and age. Might be better to
    build on a later OS that supports "kernel threads" although even then,
    my understanding is that threads and signals do not always easily mix.

    rick jones
    --
    The glass is neither half-empty nor half-full. The glass has a leak.
    The real question is "Can it be patched?"
    these opinions are mine, all mine; HP might not want them anyway...
    feel free to post, OR email to rick.jones2 in hp.com but NOT BOTH...

  3. Re: Why I could not catch the signals on HP_UX?

    Thanks for the suggestions.

    Do you mean the way we did here may cause the problem that I have?

    I have the signal handler in main(), which is in a main thread. I
    thought that it applys to the all the threads in the process.
    Eventhough, my callback thread is a different thread than where the
    signal handler is initialized, does it have trouble to catch the
    signal?

    Thanks
    Sandy


  4. Re: Why I could not catch the signals on HP_UX?

    A correction here: We build it on HP_UX11.0.

    Thanks
    Sandy


  5. Re: Why I could not catch the signals on HP_UX?

    Sandy wrote:
    > Thanks for the suggestions.


    > Do you mean the way we did here may cause the problem that I have?


    > I have the signal handler in main(), which is in a main thread. I
    > thought that it applys to the all the threads in the process.
    > Eventhough, my callback thread is a different thread than where the
    > signal handler is initialized, does it have trouble to catch the
    > signal?


    I am not fully "up" on all the specifics of threads and signals, but
    am fairly confident that you cannot initialize a signal handler in one
    thread and expect another thread to catch that signal.

    It may help to peruse the manpage for signal in section 5 "man 5 signal"

    rick jones
    --
    denial, anger, bargaining, depression, acceptance, rebirth...
    where do you want to be today?
    these opinions are mine, all mine; HP might not want them anyway...
    feel free to post, OR email to rick.jones2 in hp.com but NOT BOTH...

  6. Re: Why I could not catch the signals on HP_UX?

    In <1119569749.405150.75950@f14g2000cwb.googlegroups.c om> "Sandy" writes:

    >Hi HP_UX gurus,


    Well, I was, but that's almost 3 years ago. I'll try.

    >Here is my enviroment:


    >HOST MACHINE and OPERATING SYSTEM:
    >HPUX 9000, CPU: B2600, build on HP_UX11.20, tested on HP_UX11i
    >COMPILER NAME AND VERSION (AND PATCHLEVEL):
    >config-hpux-11.00.h
    >platform_hpux_gcc.GNU


    Looks like a TAO/ACE environment?

    >I have a CORBA server which has one main thread and two private
    >threads. The two privates threads are spawned internaly, Private thread
    >1 is for monitoring other processes in the system, the private thread 2
    >is for processing events from a event queue. In thread 2, the server
    >makes a callback to a client using the object that the client
    >registered with the server.


    HPUX is strictly POSIX compilant when it comes to signals and threads,
    where did you register the signal handler? Before you're creating
    any threads?

    >When the client is terminated abnormally before the server makes the
    >callback, the object that the server uses to make callback is invalid.
    >As a result, sometimes the server gets an unknown exception (I catch it
    >with catch(...)), othertimes, the server just hang there at where it
    >makes the callback, then the server is terminated. I have added all the
    >possible signals in my signal handler, but I did not catch anything,
    >except once: I got SIGABRT over the 100 times I tried.


    Then you have called abort() or send the signal by hand. A process never
    gets SIGABORT on it's own. The signal I would expect to be thrown would
    be a SIGILL, SIGSEGV or a SIGBUS. Catching these is of limited use
    and you should better avoid the callback anyway.

    It may be that I did not understand what you are doing (it's way too hot
    here, over 30°C) and you are referring to a CORBA callback. Then, the
    call should time out... eventually. This can take a long time and is
    OS and TCP/IP settings depended. You will get an exception in this case,
    *not* a signal. It is vital to separate cleanly between signals and
    exceptions, BTW.

    >Question: why did not I catch any signal? I did not find core dump
    >either.


    First, I would check if you are allowed to dump core at all. Check your
    shell or ulimit settings.

    >There must be a signal sent to the process to cause it to be
    >terminated, correct? If so, how do I catch it? Is there any other way
    >to cause a process to die?


    Sure. I know that some g++'s on hppa had problems catching C++ exceptions
    which were thrown inside shared libraries. It's most probably fixed in
    a more recent g++ library, check the release notes of your version.

    HTH,
    Uli
    --
    Dipl. Inf. Ulrich Teichert|e-mail: Ulrich.Teichert@gmx.de
    Stormweg 24 |listening to: Suicide Drive (The Deep Eynde)
    24539 Neumuenster, Germany|Public Pervert (Interpol) Cauchemar (Opération S)

  7. Re: Why I could not catch the signals on HP_UX?

    "Sandy" wrote in message
    news:1119569749.405150.75950@f14g2000cwb.googlegro ups.com...
    > Hi HP_UX gurus,
    >
    > Here is my enviroment:
    >
    > HOST MACHINE and OPERATING SYSTEM:
    > HPUX 9000, CPU: B2600, build on HP_UX11.20, tested on HP_UX11i
    > COMPILER NAME AND VERSION (AND PATCHLEVEL):
    > config-hpux-11.00.h
    > platform_hpux_gcc.GNU
    >
    >
    > I have a CORBA server which has one main thread and two private
    > threads. The two privates threads are spawned internaly, Private thread
    > 1 is for monitoring other processes in the system, the private thread 2
    > is for processing events from a event queue. In thread 2, the server
    > makes a callback to a client using the object that the client
    > registered with the server.
    >
    > When the client is terminated abnormally before the server makes the
    > callback, the object that the server uses to make callback is invalid.
    > As a result, sometimes the server gets an unknown exception (I catch it
    > with catch(...)), othertimes, the server just hang there at where it
    > makes the callback, then the server is terminated. I have added all the
    > possible signals in my signal handler, but I did not catch anything,
    > except once: I got SIGABRT over the 100 times I tried.
    >
    > Question: why did not I catch any signal? I did not find core dump
    > either. There must be a signal sent to the process to cause it to be
    > terminated, correct? If so, how do I catch it? Is there any other way
    > to cause a process to die?
    >
    > Any suggestions?
    >



    Your write-up is not entirely clear as to
    when/where the signal handlers are set up.

    Note however that the system calls to set
    up signal masks and handlers only affect
    the lwp that sets up the signal mask and
    the handlers. This is well documented in
    section 2 of the reference manual.



    dk



    dk



  8. Re: Why I could not catch the signals on HP_UX?

    : When the client is terminated abnormally before the server makes the
    : callback, the object that the server uses to make callback is invalid.
    : As a result, sometimes the server gets an unknown exception (I catch it
    : with catch(...)),

    Note it isn't supported to throw out of a signal handler with aC++:
    /opt/aCC/newconfig/RelNotes/ACXX.release.notes
    Known limitations of signal handling features:

    : I have added all the possible signals in my signal handler

    You should not arm SIGTRAP.

  9. Re: Why I could not catch the signals on HP_UX?

    Thanks for all your suggestions.

    I have set the following signals in the main() :

    void setSignals()
    {
    int signum;
    struct sigaction vec;

    for (signum = 1; signum <= NSIG; signum++)
    {
    (void) signal(signum, SIG_IGN);
    }

    sigemptyset( &vec.sa_mask );
    sigaddset( &vec.sa_mask, SIGCHLD );
    vec.sa_flags = 0;
    vec.sa_handler = serverExitSignalHandler
    /** CAPTURE TERMINAL SIGNAL EVENTS **/
    if (sigaction(SIGTERM,&vec,NULL) == -1 ||
    #if defined(SIGEMT_SUPPORTED)
    sigaction(SIGEMT,&vec,NULL) == -1 ||
    #endif /* defined(SIGEMT_SUPPORTED) */
    sigaction(SIGFPE,&vec,NULL) == -1 ||
    sigaction(SIGILL,&vec,NULL) == -1 ||
    sigaction(SIGPIPE,&vec,NULL) == -1 ||
    sigaction(SIGALRM,&vec,NULL) == -1 ||
    sigaction(SIGINT,&vec,NULL) == -1 ||
    sigaction(SIGPOLL,&vec,NULL) == -1 ||
    sigaction(SIGPROF,&vec,NULL) == -1 ||
    sigaction(SIGUSR2,&vec,NULL) == -1 ||
    sigaction(SIGVTALRM,&vec,NULL) == -1 ||
    sigaction(SIGQUIT,&vec,NULL) == -1 ||
    //sigaction(SIGBUS,&vec,NULL) == -1 ||
    //sigaction(SIGSEGV,&vec,NULL) == -1 ||
    sigaction(SIGSYS,&vec,NULL) == -1)
    /*sigaction(SIGCHLD,&vec,NULL) == -1 )*/
    {
    exit (1);
    }

    // Handle special case of SIGSEGV and SIGBUS when it occurs in
    NotifyObservers

    vec.sa_handler = notExitSigHandler;
    if ( sigaction(SIGBUS,&vec,NULL) == -1 ||
    sigaction(SIGSEGV, &vec, NULL) == -1 ||
    sigaction(SIGABRT, &vec, NULL) == -1 ||
    sigaction(SIGHUP, &vec, NULL) == -1)
    {
    exit(1);
    }

    vec.sa_handler=dbgHandler;
    if (sigaction(SIGUSR1,&vec,NULL) == -1)
    {
    exit (1);
    }
    }

    The callback is on anther thread, but I tried to do a raise(SIGSEGV) in
    the server's call back function just to test if the server can catch
    the signal. I found it get and the notExitSigHandler() is called. But
    in real case, which mean when I call the callback using the client's
    invalid object, the server is terminated without catching any signal
    first.

    The callback is a CORBA callback, Sometimes, I got a CORBA exception,
    but not always. (I think it is a bug in CORBA.), other times, I have
    the problem that I described above. I am trying to cover that problem
    in my code by catching the signal and redirect it to my handler instead
    of the system default handler. I want the code to continue to do
    callback to other clients in the list instead of just terminates the
    process. So the notExitSigHandler is to throw an exception to the
    server's callback function... But since I can not catch this signal, I
    can not do anything about it.

    Thanks
    Sandy


  10. Re: Why I could not catch the signals on HP_UX?

    Hi,

    [del]
    >The callback is on anther thread, but I tried to do a raise(SIGSEGV) in
    >the server's call back function just to test if the server can catch
    >the signal. I found it get and the notExitSigHandler() is called. But
    >in real case, which mean when I call the callback using the client's
    >invalid object, the server is terminated without catching any signal
    >first.

    [del]

    Depending on the TCP/IP implementation on HPUX, you might get a SIGPIPE
    from a broken TCP connection. Try adding this to your signal handler,
    but it depends highly upon the underlying ORB which does the network
    handling if this will get you further.

    Catching signals like SIGSEGV or SIGBUS is of limited value, unless you
    can be sure that your thread is either destroyed/cancelled without repeating
    the faulty access *and* the variable/member in question is released or
    overwritten. But I am repeating myself....

    HTH,
    Uli
    --
    Dipl. Inf. Ulrich Teichert|e-mail: Ulrich.Teichert@gmx.de
    Stormweg 24 |listening to: Suicide Drive (The Deep Eynde)
    24539 Neumuenster, Germany|Public Pervert (Interpol) Cauchemar (Opération S)

  11. Re: Why I could not catch the signals on HP_UX?

    Thanks!

    I have the SIGPIPE in the signal handling already. But I did not catch
    it. I thought the ORB might have set the signal (by calling signal() or
    sigaction()) in the code which may overwrited what is in my server app.
    But Dr. Schmidt, the CORBA guru, said the ORB does not set signals in
    its code.

    My experience is under gcc, the server is not able to catch signal 100%
    times, why?

    Thanks
    Sandy


  12. Re: Why I could not catch the signals on HP_UX?

    In <1119995809.800950.117440@g43g2000cwa.googlegroups. com> "Sandy" writes:

    >Thanks!


    >I have the SIGPIPE in the signal handling already. But I did not catch
    >it. I thought the ORB might have set the signal (by calling signal() or
    >sigaction()) in the code which may overwrited what is in my server app.
    >But Dr. Schmidt, the CORBA guru, said the ORB does not set signals in
    >its code.


    He's the authority in this case, as he did most of the design and wrote
    the initial code base. So, the ORB does not send signals and your signal
    handlers are useless. Trust him ;-)

    >My experience is under gcc, the server is not able to catch signal 100%
    >times, why?


    This has nothing to do with signals then, but with exceptions, I think.
    Which gcc version are you using? Earlier than 3.2.*?

    HTH,
    Uli
    --
    Dipl. Inf. Ulrich Teichert|e-mail: Ulrich.Teichert@gmx.de
    Stormweg 24 |listening to: Suicide Drive (The Deep Eynde)
    24539 Neumuenster, Germany|Public Pervert (Interpol) Cauchemar (Opération S)

+ Reply to Thread