FATAL:Exception occured when pthread_exit() used

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • platso
    New Member
    • Nov 2007
    • 4

    FATAL:Exception occured when pthread_exit() used

    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_f unction( void *ptr );

    int main()

    {

    pthread_t thread1;

    char *message1 = "Thread 1";

    int iret1;



    iret1 = pthread_create( &thread1, NULL, (void*(*)(void* ))&print_messag e_function, (void*) message1);



    pthread_join( thread1, NULL);





    }



    void print_message_f unction( void *ptr )

    {

    char *message;

    message = (char *) ptr;



    try

    {

    pthread_exit((v oid*) 1);

    }

    catch(...)

    {

    printf("Inside catch...\n");

    }

    }

    CAN ANY ONE TELL ME THE REASON WHY EXCEPTION OCCURED?
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    Originally posted by platso
    pthread_exit((v oid*) 1);
    I'm no Linux expert, but do you really mean to convert 1 to an address??

    Comment

    Working...