Back Midas Rome Roody Rootana
  Midas DAQ System  Not logged in ELOG logo
Entry  12 Dec 2012, Shaun Mead, Bug Report, ss_thread_kill() kills entire program 
    Reply  13 Dec 2012, Stefan Ritt, Bug Report, ss_thread_kill() kills entire program 
    Reply  13 Dec 2012, Konstantin Olchanski, Bug Report, ss_thread_kill() kills entire program 
       Reply  13 Dec 2012, Shaun Mead, Bug Report, ss_thread_kill() kills entire program 
Message ID: 844     Entry time: 13 Dec 2012     In reply to: 843
Author: Shaun Mead 
Topic: Bug Report 
Subject: ss_thread_kill() kills entire program 
> > Hi, I'm having some trouble getting ss_thread_kill() to work properly. It seems 
> > to kill the entire program instead of just the thread.
> 
> You cannot kill a thread. It's not a well defined operation. Most OSes do have the 
> technical possibility to kill threads, but if you use them, you will not like the 
> results. For a taste of small trouble, if a thread is holding a lock and you kill 
> it, who's job is it to release the lock?
> 
> The best you can do is to ask the thread to gracefully shutdown itself. (I.e. by 
> using global variable flags).
> 
> P.S. I did not implement the ss_thread stuff, I do not know what ss_thread_kill() 
> does, but I recommend that you do not use it.
> 
> P.P.S. Programming using threads is complicated, I recommend that you read at least 
> some literature on the topic before using threads. At the least you must understand 
> the common pitfalls and mistakes. At the least, you must know about deadlocks, 
> livelocks, race conditions and semaphore priority inversions.
> 
> K.O.

Yes, but unfortunately what I was attempting to do was use a library function that I
can't alter. It sometimes gets stuck and I wanted a way to kill it. Anyway I ended up
not doing this at all in c++; I was able to do what I needed in python.

Shaun
ELOG V3.1.4-2e1708b5