473,385 Members | 1,888 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

invalid threads ID

Hello, I´m implementing an multithread application under linux with
gcc and kdevelop. I use pthread library from linux to handle threads
and mutex. My question is how can my program detect if a thread struct
is still valid or active.... I use a library that call a function
pthread_kill (threadID,0) in order to detect if a thread is alive but
when the thread Id is invalid, it causes a segmentation fault.
Ex:
if (threadID==0)
return FALSE;

if (pthread_kill(threadID,0)!=0)
{
......
return TRUE;
}
else
{
.......
return FALSE;
}
Thanks

Jul 23 '05 #1
2 2981
martini wrote:
Hello, I´m implementing an multithread application under linux with
gcc and kdevelop. I use pthread library from linux to handle threads
and mutex. My question is how can my program detect if a thread struct
is still valid or active.... I use a library that call a function
pthread_kill (threadID,0) in order to detect if a thread is alive but
when the thread Id is invalid, it causes a segmentation fault.


Since C++ has no means for multithreaded programming, your best bet is
to ask in either the newsgroup for your OS or in comp.programming.threads.

V
Jul 23 '05 #2
Ian
martini wrote:
Hello, I´m implementing an multithread application under linux with
gcc and kdevelop. I use pthread library from linux to handle threads
and mutex. My question is how can my program detect if a thread struct
is still valid or active.... I use a library that call a function
pthread_kill (threadID,0) in order to detect if a thread is alive but
when the thread Id is invalid, it causes a segmentation fault.
Last time I looked, pthread_t on Linux was an opaque type, a pointer to
an internal struct. So it may be non-null and still invalid.
Ex:
if (threadID==0)
return FALSE;

Try to avoid nasty macros like TRUE and FALSE.

Ian
Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Michael Schutte | last post by:
I know, questions about Tkinter and threads have been answered very often, but I want to ask anyway. I am using Python 2.2 on a Linux (SuSE Linux 8.1) system. I want to write a server application;...
1
by: Josef Meile | last post by:
Hi, I'm trying to do a simple link checking for python 2.1.3 (compiled from source on linux), but it fails when I use an invalid ssl url. For example: I have zope without ssl running on port...
0
by: dsclements | last post by:
>Description: I'm running mysql in a 3 server configuration, with 2 servers being slaves to the first. I'm running vpopmail, which means a connection every incoming mail and every check. I woke up...
1
by: Owen Jenkins | last post by:
I have found references to this problem in several threads on this newsgroup but none provide an answer to explain this problem. So any further assistance would be very helpful... I have 2 forms...
7
by: Søren Dreijer | last post by:
Hi, I have a mixed C#, managed C++ and unmanaged C++ project. The managed class calls a method which exists in an unmanaged singleton class. During the entire lifetime of the application, this...
5
by: Brian Richards | last post by:
I'm experiencing some wierd behavior with a Dictionary<T,U> class using foreach loops, such that the Key returned in the foreach is not contained in the dictionary. code: Dictionary<A, B>...
3
by: wolverine | last post by:
Hi I am accessing a map from inside threads. There is a chance that an element is inserted into the map, from inside any thread. Since i don't know about thread safety of stl implementation i am...
2
by: jane | last post by:
We are getting this error every other day during the ETL run. It seems to be random. What is the best solution? DB2 AIX 8.1.5. COM.ibm.db2.jdbc.DB2Exception: CLI0601E Invalid statement...
8
by: khalid302 | last post by:
I'm writing a multi-threaded application where one thread waits for a certain std::set element to be deleted by another thread. The waiting thread already has an iterator pointing at the element...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.