about exception type issuse

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Dear All

    I write the following code,and get the an unknow exception.Would any
body tell me what the exception is?why it can be catched by
catch(...),but can not be catched by user's code.

best,
Guanjun

code:
#include <stdio.h>
#include <pthread.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdexcept>
#include <ios>
#include <fstream>
#include <csignal>
#include <iostream>
#include <exception>
#include <exception_defines.h>
#include <unwind.h>
typedef unsigned _Unwind_Exception_Class
__attribute__((__mode__(__DI__)));

void *thread(void*)
{
        int i;
        pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, 0);

pthread_setcanceltype(/*PTHREAD_CANCEL_ASYNCHRONOUS*/PTHREAD_CANCEL_DEFERRED, 0);
        try
        {
                for(i=0;/*i<3*/;i++) {
                        //pthread_testcancel();
                        printf("This is a pthread.\n");
                        //pthread_testcancel();
                }
        }catch(.../*_Unwind_Reason_Code &n*//*struct _Unwind_Exception
&b*//*_Unwind_Exception_Class &u*/)
        {
                printf("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^This
is the child thread: \n");/*%d .\n", n);*/
                //throw;
                //a.what();
                /*do nothing*/
        }
        return 0;
}

int main(void)
{
        pthread_t id;
        int ret;
        ret=pthread_create(&id,NULL, thread,NULL);
        if(ret!=0){
                printf ("Create pthread error!\n");
                exit (1);
        }
        usleep(100);
        printf("********************This is the main thread.\n");
        pthread_cancel(id);
        printf("********************This is the main thread.\n");
        //pthread_join(id,0);
        return (0);
}








[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux