472,143 Members | 1,724 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

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 2673
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
reply views Thread by Saiars | last post: by
reply views Thread by leo001 | last post: by

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.