The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
Google UNIX.COM


High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
kill(0,-9) don't kill the process umen High Level Programming 9 06-19-2007 03:09 AM
how to start a process and make it sleep for 5 mins and then kill that process shrao Shell Programming and Scripting 6 03-27-2007 09:54 AM
how to kill threads in solaris izy100 UNIX for Advanced & Expert Users 9 01-07-2007 07:51 PM
When kill doesnt work, how to kill a process ? VijayHegde UNIX for Advanced & Expert Users 3 05-12-2006 01:24 PM
threads per process digdarshan UNIX for Advanced & Expert Users 0 04-21-2004 04:19 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 07-31-2008
Registered User
 

Join Date: Jun 2008
Posts: 3
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 seconds without waiting for the child thread completion.

To accomplish the above task, I created a detachable tracker thread for each poll of memcache which in turn creates worker threads n joins them.

so my main tracker thread need not wait for the detached thread and can start polling the cache at a stipulated time.

Now, when i tried to give a "kill <process_id>", i observed that only my main thread is killed whereas the detached thread and worker threads are still running!!!

Ideally , a kill to main should quit all my detached threads too...ne ideas/thoughts on how to handle this?? Kindly help
Reply With Quote
Forum Sponsor
  #2  
Old 07-31-2008
Technorati Master
 

Join Date: Mar 2005
Location: Large scale systems...
Posts: 2,610
kill command is for a process ( which in turn is the main thread ) and not for sub threads created out of main thread.

Shouldn't the main thread have a signal handler to kill all the threads it had created ( if it has to ) before exiting ?
Reply With Quote
  #3  
Old 07-31-2008
Registered User
 

Join Date: Dec 2007
Location: Virginia, USA.
Posts: 250
Not enough details.
A signal that terminates a single multithreaded process, as matrix notes, should terminate all threads.
That being said I don't know what the default result for SIGTERM is in your environment
Signals and threads are always a problem. If there is a way to avoid this kind of situation I'd suggest trying hard to do it.

What it sounds like (naively) is that you need to ignore all signals in tracker and workers and use thread conditionals (events)..for pthreads: man -k pthread_cond.

Last edited by ramen_noodle; 07-31-2008 at 11:16 AM.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 09:58 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0