469,934 Members | 2,497 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,934 developers. It's quick & easy.

FATAL:Exception occured when pthread_exit() used

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


This is on Linux platform.

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 EXCEPTION OCCURED?
Nov 29 '07 #1
1 2535
weaknessforcats
9,208 Expert Mod 8TB
pthread_exit((void*) 1);
I'm no Linux expert, but do you really mean to convert 1 to an address??
Nov 29 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

10 posts views Thread by Developwebsites | last post: by
2 posts views Thread by Ray Cassick \(Home\) | last post: by
7 posts views Thread by Jacek Dziedzic | last post: by
1 post views Thread by Jarek | last post: by
4 posts views Thread by D'artagnan | last post: by
3 posts views Thread by Miro | last post: by
4 posts views Thread by leelaprasad.gorrepati | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.