11-29-2007
FATAL:exception occured with pthread_exit()
We had written an application in which we create worker thread.
So the main thread will create the worker thread. After some time
the child thread(Worker thread) will call pthread_exit().
This function was written in try{} and there occured an Exception
and is handled in catch(...) handler.
Can any one tell me the reason why the exception occured.
This is on Linux platform. Fedora Core 6 and gcc 4.1
The Implementation of the code is as follows:
This is a simple form of our application, Try to run this small piece
of code.
The output of this is " FATAL: exception not rethrown
Inside catch... Aborted"
#include <stdio.h>
#include <stdlib.h>
#include <stdexcept.h>
#include <pthread.h>
using namespace std;
void print_message_function( void *ptr );
int main()
{
pthread_t thread1;
char *message1 = "Thread 1";
int iret1;
iret1 = pthread_create( &thread1, NULL, (void*(*)(void*))&print_message_function, (void*) message1);
pthread_join( thread1, NULL);
}
void print_message_function( void *ptr )
{
char *message;
message = (char *) ptr;
try
{
pthread_exit((void*) 1);
}
catch(...)
{
printf("Inside catch...\n");
}
}
Can any one tell me the reason why the exception occured?
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
hi,
cud u help me to find this.
i hav 2 files.
file1 has data as "ARUN
ARUN is from Australia
Arun likes America etc..
ARUN ARUN "
file2 has "ARUN
Australia
America"
i... (5 Replies)
Discussion started by: arunsubbhian
5 Replies
2. UNIX for Advanced & Expert Users
HI,
My Machine is running on RHEL3, Its not booting. When I try to boot in rescue mode.Its giving the following err:
" Kernel panic : Fatal exception "
Can any one tel me how to get rid of this error? (3 Replies)
Discussion started by: praveen_b744
3 Replies
3. Programming
Main function creates Thread0 and Thread1 by using pthread_create systemcall.
In Thread0() {
we are calling pthread_exit(0) ;
}
and in Thread1() {
status= pthread_join(tid,NULL);
sprintf(ebuf,"timer6: can't join with thread0, status: %d",status);
Assert(status==0,ebuf);
}
... (4 Replies)
Discussion started by: mansa
4 Replies
4. UNIX Desktop Questions & Answers
Hi ALL,
I am getting error..
kernal panic-not syncing:fatal exception
while booting.
Please help me..
Thanks
Jack (7 Replies)
Discussion started by: jack00423
7 Replies
5. UNIX for Advanced & Expert Users
Hi All,
In my application, I'm getting an error as type mismatch
Let me now explain the scenario,
I ran a shell script which calls some other scripts. All these scripts uses the environment variables.
Take for example, this script uses a variable 'PathDir'. I initiallized the value to... (2 Replies)
Discussion started by: iamgeethuj
2 Replies
6. Programming
Hi...
this simple code has warning messages but it work..
void *th(void *g){
int y = 10;
pthread_exit((void*)y);
}
int main(int argn, char ** argp){
void * ret;
pthread_t thread;
pthread_create(&thread, NULL, th, NULL);
pthread_join(thread,... (10 Replies)
Discussion started by: prompt
10 Replies
7. Programming
Hi,
I am new to multithreaded programming. When creating a thread to run a specific function, does the function need to have a pthread_exit ?
Is pthread_exit analogous to a return in a function? (3 Replies)
Discussion started by: sanjayc
3 Replies
8. Shell Programming and Scripting
Hello to all in forum,
I need to count how many events happens within each second for 01 Aug 2013.(because in the sample appears records for 01 Aug and 02 Aug).
The output for the input below should be:
Desired Output:
--> 2 Records
--> 1 Record
--> 3 Records
Input:
DEBUG... (5 Replies)
Discussion started by: Ophiuchus
5 Replies
9. Shell Programming and Scripting
Hi Folks,
please advise , I have logs generated on unix machine at location /ops/opt/aaa/bvg.log , now sometimes there come exception in these logs also, so I want to write such a script such that it should continuously monitor these logs and whenever any exception comes that is it try to find... (3 Replies)
Discussion started by: tuntun27272727
3 Replies
10. What is on Your Mind?
Today, I noticed some errors in our SSL cert renewal log files, mostly related to domains where the IP address had changed. Concerned about this, rebuilt out SSL cert, which normally goes well without a hiccup.
However, for today, for some reason which I cannot explain, there was a PHP error... (0 Replies)
Discussion started by: Neo
0 Replies
LEARN ABOUT SUNOS
pthread_exit
pthread_exit(3C) pthread_exit(3C)
NAME
pthread_exit - terminate calling thread
SYNOPSIS
cc -mt [ flag... ] file... -lpthread [ library... ]
#include <pthread.h>
void pthread_exit(void *value_ptr);
The pthread_exit() function terminates the calling thread, in a similar way that exit(3C) terminates the calling process. If the thread is
not detached, the exit status specified by value_ptr is made available to any successful join with the terminating thread. See
pthread_join(3C). Any cancellation cleanup handlers that have been pushed and not yet popped are popped in the reverse order that they were
pushed and then executed. After all cancellation cleanup handlers have been executed, if the thread has any thread-specific data, appropri-
ate destructor functions will be called in an unspecified order. Thread termination does not release any application visible process
resources, including, but not limited to, mutexes and file descriptors, nor does it perform any process level cleanup actions, including,
but not limited to, calling any atexit() routines that might exist.
An implicit call to pthread_exit() is made when a thread other than the thread in which main() was first invoked returns from the start
routine that was used to create it. The function's return value serves as the thread's exit status.
The behavior of pthread_exit() is undefined if called from a cancellation cleanup handler or destructor function that was invoked as a
result of either an implicit or explicit call to pthread_exit().
After a thread has terminated, the result of access to local (auto) variables of the thread is undefined. Thus, references to local vari-
ables of the exiting thread should not be used for the pthread_exit() value_ptr parameter value.
The process exits with an exit status of 0 after the last thread has been terminated. The behavior is as if the implementation called
exit() with a 0 argument at thread termination time.
The pthread_exit() function cannot return to its caller.
No errors are defined.
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Interface Stability |Standard |
+-----------------------------+-----------------------------+
|MT-Level |MT-Safe |
+-----------------------------+-----------------------------+
exit(3C), pthread_cancel(3C), pthread_create(3C), pthread_join(3C), pthread_key_create(3C), attributes(5), standards(5)
23 Mar 2005 pthread_exit(3C)