LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   How to kill a user thread in Linux.... Help me (https://www.linuxquestions.org/questions/programming-9/how-to-kill-a-user-thread-in-linux-help-me-314872/)

rajsun 04-19-2005 08:57 AM

How to kill a user thread in Linux.... Help me
 
Hi all,
I want to kill a thread spawned by main thread from main thread.
Before the complition of the spawned thread.
I want to know how can i accomplish this task.... ? If any one know plz hepl me...

With Regard
Rajesh.

kees-jan 04-19-2005 09:49 AM

Uh...
What thread library are you using? What programming language? Maybe some example code of what you are trying to do?

Groetjes,

Kees-Jan

sgrayban 04-19-2005 12:18 PM

thread or process?

Marius2 04-20-2005 02:25 AM

If you are using POSIX threads: keep the pthread_t which is is returned by pthread_create (that is, the thread handle). To kill the thread, use pthread_kill with said pthread_t passed as argument.


HTH

rajsun 04-20-2005 04:13 AM

Thanks all to respond my query. Actully i m using POSIX thread in C and Linux. I got the solution by doing some thing here and there. The answer is :
To terminate a user thread prematurely use the API "pthread_cancel" from the thread which want to kill the target thread.

For the furthre details about pthread library follw the following link :
----------------------------------------------------------------------------
http://publib.boulder.ibm.com/iserie...s/users_97.htm
----------------------------------------------------------------------------

hanks all.


All times are GMT -5. The time now is 01:45 AM.