how to kill threads in solaris


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users how to kill threads in solaris
# 1  
Old 01-04-2007
how to kill threads in solaris

Any idea how to kill threads (not processes) in solaris?
I had checked the man pages for both kill and pkill to no avail.
# 2  
Old 01-04-2007
You can't.
# 3  
Old 01-05-2007
Any reason why?
# 4  
Old 01-05-2007
Becasue that's not the way the kernel is written.
# 5  
Old 01-06-2007
Removed post....missunderstood request
Tornado
# 6  
Old 01-06-2007
izy100, "kill" means "send a signal to". Signals get complicated real fast in a multi-threaded program. Best practice is for a multi-threaded process to have a dedicated signal acceptor thread (for lack of a better term) that has called sigwait. It then may invoke pthread_kill to signal some particular thread. Remember that if a thread who is not expecting a signal somehow gets one anyway, for the most part, one of two things will happen:

1. the signal will be ignored
2. the thread will behave as if it called exit(), thus destroying the entire process

In either case, it doesn't matter that much which thread was involved.

Threads cease to exist when they return from their main function or call pthread_exit. The thread is said to be cancelled. One thread can call pthread_cancel to try to cancel another thread. But threads may render themselves uncancelable. And processes rarely create superfluous or even expendable threads... in most cases, if one thread dies, the whole process must die with it.
# 7  
Old 01-06-2007
tks for the info. I have a multi-threaded socket program that handles incoming connection from 100 clients. Each thread handles 1 connection and 1 client's request typically take < 5 seconds for a thread to handle before the thread perish.

Due to all types of reasons that happen over the past few years, e.g.: client program has bugs, issue with firewall setting btw the socket server and the clients, socket program has bugs, etc....., one of the common problem they caused is unclosed thread at the server server's end.

I am thinking if it is possible to write an external monitoring program that monitors for idle thread for > 5 seconds and send a signal to the thread to 'kill' it.

Perderabo, does that means my idea is undo-able?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Solaris, grant user to kill another process

the task is grant user1 to kill another (for example user2) process. My steps: by root: usermod -P "Process Management" user1 login user1 user1@server (~) pfexec kill <PID> the result is: ksh: <PID>: not found or user1@server (~) pfexec pkill <PID> the result: nothing happens, still... (0 Replies)
Discussion started by: dsyberia
0 Replies

2. Solaris

Way to find source of a kill -9 in Solaris

Hello Guys, Someone or, some tool has killed the application process with signal 9 (kill -9) . How to track that in Solaris? On AIX we can use light-weight tool called ProbeVue to track it but not sure how to do it on Solaris. Appreciate your help. Kelly (3 Replies)
Discussion started by: aixusrsys
3 Replies

3. UNIX for Advanced & Expert Users

How to kill a thread among several threads belongs to a process?

I would like to know is there any we can kill a single thread among multiple threads belongs to process? Since Signal action is process wise not per thread, i strongly feel that we can not or for that mater from external sources as well single thread can not be killed which is critical section... (2 Replies)
Discussion started by: murali242512
2 Replies

4. Shell Programming and Scripting

How to start multiple threads in Solaris?

Hello, In a unix Solaris environment, (for simulation) how to start multiple threads (as Light Weight Process, not background process)? thanks, J. (7 Replies)
Discussion started by: seafan
7 Replies

5. Shell Programming and Scripting

Kill an specific process ID using the KILL and GREP commands

Good afternoon I need to KILL a process in a single command sentence, for example: kill -9 `ps -aef | grep 'CAL255.4ge' | grep -v grep | awk '{print $2}'` That sentence Kills the process ID corresponding to the program CAL255.4ge. However it is possible that the same program... (6 Replies)
Discussion started by: enriquegm82
6 Replies

6. Shell Programming and Scripting

Shell Script to Kill Process(number of process) Unix/Solaris

Hi Experts, we do have a shell script for Unix Solaris, which will kill all the process manullay, it used to work in my previous env, but now it is throwing this error.. could some one please help me to resolve it This is how we execute the script (and this is the requirement) ... (2 Replies)
Discussion started by: jonnyvic
2 Replies

7. Shell Programming and Scripting

Kill a process without using kill command

Sorry, posted the question in other forum. (0 Replies)
Discussion started by: sudhamacs
0 Replies

8. Programming

Can SIGTERM to main process kill the detached threads?

Hi, I am stuck up with a strange problem. I am writing an application - a kinda tracker that reads data from memcache and invokes theads to process each record of the memcache. I dont want to join all my threads because my tracker should poll the cache in regular intervals say sum 300... (2 Replies)
Discussion started by: deepti_v25
2 Replies

9. UNIX for Advanced & Expert Users

When kill doesnt work, how to kill a process ?

Hi All, I am unable to kill a process using kill command. I am using HP-UX system. I have tried with kill -9 and i have root privilages. How can i terminate this daemon ? ? ? Regards, Vijay Hegde (3 Replies)
Discussion started by: VijayHegde
3 Replies

10. UNIX for Dummies Questions & Answers

kill scripts under Solaris

I should know this, but do K scripts in the /etc/rc?.d directories get run in numerically ascending or descending order? By default there are none in rc3.d. Is it OK to put 2 in there, and will they be run first (which is my goal). Thanks, Chuck (1 Reply)
Discussion started by: 98_1LE
1 Replies
Login or Register to Ask a Question