Visit The New, Modern Unix Linux Community

Linux and UNIX Man Pages

Test Your Knowledge in Computers #989
Difficulty: Medium
OpenBSD includes no third-party components.
True or False?
Linux & Unix Commands - Search Man Pages

pthread_kill_other_threads_np(3) [redhat man page]


pthread_kill_other_threads_np - terminate all threads in program except calling thread SYNOPSIS
#include <pthread.h> void pthread_kill_other_threads_np(void); DESCRIPTION
pthread_kill_other_threads_np is a non-portable LinuxThreads extension. It causes all threads in the program to terminate immediately, except the calling thread which proceeds normally. It is intended to be called just before a thread calls one of the exec functions, e.g. execve(2). Termination of the other threads is not performed through pthread_cancel(3) and completely bypasses the cancellation mechanism. Hence, the current settings for cancellation state and cancellation type are ignored, and the cleanup handlers are not executed in the terminated threads. AUTHOR
Xavier Leroy <> SEE ALSO
execve(2), pthread_setcancelstate(3), pthread_setcanceltype(3), pthread_cancel(3). BUGS
According to POSIX 1003.1c, a successful exec* in one of the threads should terminate automatically all other threads in the program. This behavior is not yet implemented in LinuxThreads. Calling pthread_kill_other_threads_np before exec* achieves much of the same behavior, except that if exec* ultimately fails, then all other threads are already killed. LinuxThreads PTHREAD_KILL_OTHER_THREADS_NP(3)

Check Out this Related Man Page


pthread_kill_other_threads_np - terminate all other threads in process SYNOPSIS
#include <pthread.h> void pthread_kill_other_threads_np(void); DESCRIPTION
pthread_kill_other_threads_np() only has an effect in the LinuxThreads threading implementation. On that implementation, calling this function causes the immediate termination of all threads in the application, except the calling thread. The cancellation state and cancel- lation type of the to-be-terminated threads are ignored, and the cleanup handlers are not called in those threads. CONFORMING TO
This function is a nonstandard GNU extension; hence the suffix "_np" (nonportable) in the name. NOTES
pthread_kill_other_threads_np() is intended to be called just before a thread calls execve(2) or a similar function. This function is designed to address a limitation in the obsolete LinuxThreads implementation whereby the other threads of an application are not automati- cally terminated (as POSIX.1-2001 requires) during execve(2). In the NPTL threading implementation, pthread_kill_other_threads_np() exists, but does nothing. (Nothing needs to be done, because the implementation does the right thing during an execve(2).) SEE ALSO
execve(2), pthread_cancel(3), pthread_setcancelstate(3), pthread_setcanceltype(3), pthreads(7) COLOPHON
This page is part of release 3.44 of the Linux man-pages project. A description of the project, and information about reporting bugs, can be found at Linux 2010-09-09 PTHREAD_KILL_OTHER_THREADS_NP(3)

11 More Discussions You Might Find Interesting

1. Programming

Help wanted

Hi, I know very little about C and Unix. I have written a program to use threads. The program needs to get some values from a very large database. I wrote a simple program and compiled but got the following errors..... cc mythread.c -lthread "/usr/include/pthread.h", line 120:... (3 Replies)
Discussion started by: reddyb
3 Replies

2. Post Here to Contact Site Administrators and Moderators

Long threads?

Greetings, I'm relatively new-comer to these forums and have a Q to the mods. Just wondering what's the policy regarding the long running threads where they tend to go say over 30 posts and they become "troubleshooting" threads rather than being "educational" and/or "hinting" threads? ... (4 Replies)
Discussion started by: vgersh99
4 Replies

3. Shell Programming and Scripting

Spawning multiple threads in Unix

Hi, I need to spawn mutilpe threads , each invoking a different set of shell scripts, in parallel. What would be the best way to do that. Any sample script would greatly help. I am a novice at Unix so any help is much appreciated. Thanks (5 Replies)
Discussion started by: neeto
5 Replies

4. Programming

Get the no. of threads spawned in a C program

Hello Is there a way to get the no. of threads spawned by a program in C? There is no function in pthread.h that does this. :( (7 Replies)
Discussion started by: kmehta
7 Replies

5. HP-UX

Need help. Unable to create threads after a certain number

Hi, I have a process which creates pthreads to generate some reports. After creating the reports these threads return null. But after 1024 threads, the process is not able to create any threads further.,and at max 5 threads are existing simultaneously and are returning the control back after... (2 Replies)
Discussion started by: Krsh
2 Replies

6. UNIX for Advanced & Expert Users

Memory leak while using pthread_cancel()

I tried to execute a sample pthread program to cancel a newly created one using pthread_cancel(). but using valgrind on my code shows some memory leak. My Code: #include "iostream" #include "unistd.h" #include "pthread.h" #include "signal.h" using namespace std; void handler(int); void*... (4 Replies)
Discussion started by: kcr
4 Replies

7. UNIX for Advanced & Expert Users

Memory leak in pthread

helo frnds, I am using RHEL5 and C lang for development. I am getting some memory leak problem in pthread. I hav developed a program which creates two threads for listening purpose on two diff ports. both the child threads are doing same job but on diff port no. I am using... (4 Replies)
Discussion started by: mindTeaser
4 Replies

8. Shell Programming and Scripting

sed: -e expression #1, char 21: unterminated `s' command

I have read many threads, but I still didn't find the right answer. May be i didn't find the right thread, though are so many threads for the same question. Basically the situation is - find date in a file and replace it with another date. (its not homework, its part of lot of a big processing,... (10 Replies)
Discussion started by: avinthm
10 Replies

9. Solaris

Reducing threads on T5140

Hi All, We have a T5140 server which has 128 threads in total. Is it possible to reduce the number of threads per core through some configuration changes? I am sorry for being so naive but I am one on this. Why would I like to do this? Unfortunately we have this for an Oracle Database Server... (6 Replies)
Discussion started by: VENKITACHALAMS8
6 Replies

10. UNIX for Dummies Questions & Answers

Meaning of "exec 9<name" in scripts

I have found code like exec 9<filename a number of times when looking over commonly used scripts here. What all does this do? Sometimes the filename is simply a list, but seems to always have read/write/execute attributes for all. I think the "<" means to accept this as input, but don't know... (3 Replies)
Discussion started by: wbport
3 Replies

11. Shell Programming and Scripting

Deleting only 2nd and third duplicates in field 2

(7 Replies)
Discussion started by: newbie2010
7 Replies

Featured Tech Videos