Sponsored Content
Top Forums Programming Can SIGTERM to main process kill the detached threads? Post 302220193 by deepti_v25 on Thursday 31st of July 2008 05:40:02 AM
Old 07-31-2008
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!!! Smilie

Ideally , a kill to main should quit all my detached threads too...ne ideas/thoughts on how to handle this?? Kindly help
 

10 More Discussions You Might Find Interesting

1. 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

2. UNIX for Advanced & Expert Users

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. (9 Replies)
Discussion started by: izy100
9 Replies

3. Programming

kill(0,-9) don't kill the process

Hi all i have simple c program , when i wish to kill the app im using kill(0,-9) , but it seams this command don't do any thing and the program. just ignore it . what im doing wrong here ? im using HP-UX ia64 Thanks (9 Replies)
Discussion started by: umen
9 Replies

4. 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

5. Linux

Kill a process without using kill command

I want to Kill a process without using kill command as i don't have privileges to kill the process. I know the pid and i am using Linux 2.6.9 OS. (6 Replies)
Discussion started by: sudhamacs
6 Replies

6. UNIX for Dummies Questions & Answers

Run a detached process

Hey guys, Just wondering is there anyway that I would be able to run a detached process that would continue to run regardless of me being logged into the linux host? (4 Replies)
Discussion started by: killaram
4 Replies

7. Programming

Child threads communicating with main thread via pipes

I have a simple client/server program I am using for learning purposes. I have it setup so that after server is setup and listening it than goes into a loop where it accepts incoming client connections. After each connection, the client socket is than passed to a thread routine where it can be... (3 Replies)
Discussion started by: Majortom71
3 Replies

8. 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

9. Shell Programming and Scripting

ksh child process not ignoring SIGTERM

My ksh version is ksh93- =>rpm -qa | grep ksh ksh-20100621-3.fc13.i686 I have a simple script which is as below - #cat test_sigterm.sh - #!/bin/ksh trap 'echo "removing"' QUIT while read line do sleep 20 done I am Executing the script From Terminal 1 - 1. The ksh is started... (3 Replies)
Discussion started by: rpoornar
3 Replies

10. 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
PTHREAD_DETACH(3)					     Library Functions Manual						 PTHREAD_DETACH(3)

NAME
pthread_detach - put a running thread in the detached state SYNOPSIS
#include <pthread.h> int pthread_detach(pthread_t th); DESCRIPTION
pthread_detach put the thread th in the detached state. This guarantees that the memory resources consumed by th will be freed immediately when th terminates. However, this prevents other threads from synchronizing on the termination of th using pthread_join. A thread can be created initially in the detached state, using the detachstate attribute to pthread_create(3). In contrast, pthread_detach applies to threads created in the joinable state, and which need to be put in the detached state later. After pthread_detach completes, subsequent attempts to perform pthread_join on th will fail. If another thread is already joining the thread th at the time pthread_detach is called, pthread_detach does nothing and leaves th in the joinable state. RETURN VALUE
On success, 0 is returned. On error, a non-zero error code is returned. ERRORS
ESRCH No thread could be found corresponding to that specified by th EINVAL the thread th is already in the detached state AUTHOR
Xavier Leroy <Xavier.Leroy@inria.fr> SEE ALSO
pthread_create(3), pthread_join(3), pthread_attr_setdetachstate(3) LinuxThreads PTHREAD_DETACH(3)
All times are GMT -4. The time now is 01:26 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy