Menu

#700 Cancel Threads

None
unread
nobody
threads (2)
none
1
2017-10-31
2017-10-24
Mark Harsen
No

Given a threads TID, add the ability to cancel that thread from any thread with the same parent process. Sometimes there is a need to stop a thread and exceptional conditions within some quite large code prevents the thread from terminating despite my best programming efforts to flag it to terminate. A way to forcefully cause a thread to terminate would be fantastic. Thank you, -Mark

Discussion

  • Erich

    Erich - 2017-10-25

    Mark, can you elaborate?
    What kind of threads would you like to kill?
    ooRexx-created threads, e. g. from a REPLY?
    Or user-threads which attach to an interpreter instance?

    How would your program figure out the required TID?
    The parent process would be the process ooRexx is running in?
    Will your scenario apply to all operationg systems (Windows, Linux, Darwin, OpenBSD, Android etc)?
    Do you have a use case scenario, or a short piece of code that demonstrates, when/how this would be beneficial?

     
  • Mark Harsen

    Mark Harsen - 2017-10-31

    Erich, the threads I need to kill are my "console objects" which are threads started by REPLY (as you indicated). I'd assumed that these threads could query their own TID via SysQueryProcess("TID") and store it somewhere (i.e. .local["console1"]) so the main process could access it if needed. These consoles threads are started when a network administrator telnets into the system and each thread handles one user console. Sometimes a TCP connection will drop or the idle timeout will expire and the connection is closed. However sometimes, albeit rarely, a thread will hang and not terminate in spite of my efforts to get it to stop cleanly. I think they're waiting on input from the socket, but I'm not sure because I can never get one to hang when I'm trying to debug it!

    In this case, I have the TID for "console1" available, so I'd issue "SysKillThread(tid)" or something similar to cause the thread in question to be forcibly terminated.

    So, to answer your questions directly:

    • Kill threads started by a REPLY.
    • Get the TID from the thread itself while it is behaving and store it somewhere outside the thread itself.
    • Yes, the parent process would be the process ooRexx is running in.
    • I program on Windows and a little Android - it would be nice to be consistent and provide a similar service to other platforms, but I can only really speak to Windows, sorry!
    • I hope the explanation above helps - the code is far too long and complex to reproduce here.

    Thank you! -Mark

     

    Last edit: Mark Harsen 2017-10-31

Anonymous
Anonymous

Add attachments
Cancel