in reply to yet another thread/signal question

  1. why doesn't the signal fire in the thread
  2. if it does fire, how do I get rid of the 'unjoined' message at the end?

The problem fact is that signals are per-process events. So, even though you've set up a signal handler in your thread, the main thread is being interrupted by the signal before your thread ever gets a chance to see it.

The signal interrupts the th->join call in your main thread and, as you don't have a signal handler there, the process is terminated. As the the thread un-joined at that point, you get the error message.

The bottom line is that using signals and threads doesn't work.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^2: yet another thread/signal question
by markseger (Beadle) on Nov 06, 2011 at 16:23 UTC
    >The bottom line is that using signals and threads doesn't work.

    sorry to hear that. I guess I was reacting to another posting here in which this very capability was being suggested. I tried to find it to post the topic number but alas couldn't find it. I'm certain you're right because your description certainly described what I'm seeing.

    I just realized if I simply kill the ssh, the thread is able to continue and cleanly exist! Perfect, and much cleaner too. ;)

    -mark

Re^2: yet another thread/signal question
by onelesd (Pilgrim) on Nov 06, 2011 at 19:18 UTC
    My experience has been that you can get signals to a thread, but it's totally unpredictable - sometimes the child thread(s) will get the signal and sometimes the main thread gets it. Still, in the end it's not really usable.

      If you set up signal handlers in all the threads, then which one actually gets it will be (in)determined by whichever one of them next gets a time slice after the signal is raised. Ie. In the hands of the gods.


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.