Sponsored Content
Top Forums UNIX for Advanced & Expert Users How to kill a thread among several threads belongs to a process? Post 302882616 by murali242512 on Wednesday 8th of January 2014 07:09:10 AM
Old 01-08-2014
Question 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 and holding mutex.

I got confused after seeing pthread_mutexattr_setrobust() posix thread api.

Which will be used for creating robust mutex to get help when the owner get killed suddenly before release the mutex.

Thanks
--Murali Smilie
 

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

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

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

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

8. Programming

creating multiple threads using single thread id

Hi all, Can I create multiple threads using single thread_id like pthread_t thread_id; pthread_create(&thread_id, NULL, &print_xs, NULL); pthread_create(&thread_id, NULL, &print_ys, NULL); pthread_create(&thread_id, NULL, &print_zs, NULL); pthread_join(thread_id, NULL); what... (2 Replies)
Discussion started by: zing_foru
2 Replies

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

10. 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
pthread_mutexattr_getpshared(3T)										  pthread_mutexattr_getpshared(3T)

NAME
pthread_mutexattr_getpshared(), pthread_mutexattr_setpshared(), pthread_mutexattr_gettype(), pthread_mutexattr_settype() - get and set the process-shared attribute and type attribute SYNOPSIS
PARAMETERS
attr Pointer to the mutex attributes object whose attributes are to be set/retrieved. pshared This parameter either specifies the new value of the process-shared attribute (set function) or points to the memory loca- tion where the process-shared attribute of attr is to be returned (get function). type This parameter either specifies the new value of the type attribute (set function) or points to the memory location where the type attribute of attr is to be returned (get function). DESCRIPTION
The attributes object attr must have been previously initialized with the function before these functions are called. ATTRIBUTE: pshared Mutexes can be used by threads only within a process or shared by threads in multiple processes. The process-shared attribute in a mutex attributes object describes who may use the mutex. The legal values for the process-shared attribute are: This option permits a mutex to be operated upon by any thread that has access to the memory where the mutex is allocated. The application is responsible for allocating the mutex in memory that multiple processes can access. The mutex can be operated upon only by threads created within the same process as the thread that initialized the mutex. If threads of differing processes attempt to operate on such mutex, the behavior is undefined. The default value of process-shared is is used to set the process-shared attribute in attr. The new value of the process-shared attribute of attr is set to the value specified in the pshared parameter. retrieves the value of the process-shared attribute from attr. The value of the process-shared attribute of attr is returned in the pshared parameter. ATTRIBUTE: type Mutexes can be created with four different types. The type of a mutex is contained in the type attribute of the mutex attributes object. Valid values for the type attribute are: This type of mutex does not provide deadlock detection. A thread attempting to relock this mutex without first unlocking it shall deadlock. An error is not returned to the caller. Attempting to unlock a mutex locked by a different thread results in undefined behavior. Attempting to unlock an unlocked mutex results in undefined behavior. This type of mutex provides error checking. An owner field is maintained. Only the mutex lock owner shall successfully unlock this mutex. A thread attempting to relock this mutex shall return with an error. A thread attempting to unlock a mutex locked by a different thread shall return with an error. A thread attempting to unlock an unlocked mutex shall return with an error. This type of mutex is useful for debug- ging. Deadlock cannot occur with this type of mutex. An owner field is maintained. A thread attempting to relock this mutex shall successfully lock the mutex. Multiple locks of this mutex shall require the same number of unlocks to release the mutex before another thread can lock the mutex. A thread attempting to unlock a mutex locked by a different thread shall return with an error. A thread attempting to unlock an unlocked mutex shall return with an error. This type of mutex does not provide deadlock detection. A thread attempting to relock this mutex without first unlocking it shall deadlock. An error is not returned to the caller. This type of mutex can be unlocked by a thread other than the owner. Attempting to unlock an unlocked mutex results in unde- fined behavior. Attempting to recursively lock a mutex of this type results in undefined behavior. Attempting to unlock a mutex locked by a different thread results in undefined behavior. Attempting to unlock an unlocked mutex results in undefined behavior. An implementation shall be allowed to map this mutex to one of the other mutex types. The default value of the type attribute is is used to set the type attribute in attr. The new value of the type attribute of attr is set to the value specified in the type parame- ter. retrieves the value of the type attribute from attr. The value of the type attribute of attr is returned in the type parameter. Never use a mutex with condition variables because the implicit unlock performed for a or may not actually release the mutex if it had been locked multiple times. If this situation happens, no other thread can satisfy the condition of the predicate. RETURN VALUE
Upon successful completion, and return zero. Otherwise, an error number is returned to indicate the error (the variable is not set). ERRORS
If any of the following occur, the and functions return the corresponding error number: is not defined and these functions are not supported. For each of the following conditions, if the condition is detected, the and functions return the corresponding error number: attr is not a valid mutex attributes object. The value specified by pshared or type is not a legal value. The value pshared or type points to an illegal address. WARNINGS
If a mutex is created with the process-shared attribute defined as the cooperating processes should have access to the memory in which the mutex is allocated. AUTHOR
and were derived from the IEEE POSIX P1003.1c standard. and were developed by X/Open. SEE ALSO
pthread_create(3T), pthread_mutexattr_init(3T), pthread_mutex_init(3T). STANDARDS CONFORMANCE
Pthread Library pthread_mutexattr_getpshared(3T)
All times are GMT -4. The time now is 06:04 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy