CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2005
    Posts
    2

    pthread_sigmask strange behavior

    hi

    i'm trying to print all stack traces of all my thread (in a certain process), the initiative is one of these threads.

    meaning: one thread wants all traces of all his siblings.
    all i found was backtraces function that prints current thread trace.

    i started thinking that i could send a signal to each thread telling him to print its own trace.
    the thing is i dont have their id's(don't ask y).
    because i didn't find a way to get all threads ids from pthread's methods, i thought i was stuck.
    but then i thought i could sent a signal to my process, first using the sigmask to block the signal, meaning that one other thread must catch it, the handler method will order him to print his trace, and recusivly send the signal again (again, block signal first) so other threads will catch the signal.

    well, it didn't work, don't know why yet, thats where you come in
    or if you have other advise to make this simple request not so complicated(print all traces)

    anyway, the code doesn't work
    (goes into an infi. loop inside myHandler)
    void myHandler(){
    sigaddset(&signal_mask, SIGINT);
    pthread_sigmask(SIG_BLOCK, &signal_mask, NULL); // <=the problem
    printf("my handler was activated");
    sleep(1);
    kill(0, SIGINT);
    }

    thanks in dvance,
    shex

  2. #2
    Join Date
    Mar 2004
    Location
    (Upper-) Austria
    Posts
    2,899

    Re: pthread_sigmask strange behavior

    My expirience with POSIX sig's very poor but maybe this helps a bit.
    I am not offering technical guidiance via email or IM
    Come on share your photo with us! CG members photo album!
    Use the Code Tags!

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured