From: lijewski@HK.Super.NET (Mr Mike James Lijewski)
Subject: bug with DEC C++ exceptions and Pthreads
Date: 1 Nov 1994 12:02:06 +0800 [thread overview]
Message-ID: <394eju$4ji@hk.super.net> (raw)
Script started on Mon Oct 31 08:43:20 1994
% uname -a
OSF1 bsr02 V3.0 358 alpha
% cat a.C
//
// This program illustrates that the C++ exception handling function
// terminate() is maintained on a per-process basis not a per-thread
// basis. This appears to contradict the intent of the Annotated C++
// Reference Manual. In particular, in the commentary in section 15.6c
// where both terminate() and unexpected() are talked about, we have the
// following statement:
//
// Note that these functions must be specific to individual threads in a
// multi-threaded program.
//
// Compile as:
//
// cxx a.C -lpthreads -lc_r -lmach
//
#include <stdlib.h>
#include <pthread.h>
#include <stdio.h>
#ifdef __DECCXX
#include <cxx_exception.h>
#endif
class X {};
static void main_terminate_handler ()
{
(void) printf("exiting via terminate_handler() set in main() ...\n");
exit(1);
}
static void thread_terminate_handler ()
{
(void) printf("exiting via terminate_handler() set in thread ...\n");
exit(1);
}
static void* work (pthread_addr_t ignore)
{
(void) printf("Setting terminate() in a thread ...\n");
set_terminate(thread_terminate_handler);
sleep(3);
(void) printf("Exiting the thread ...\n");
return 0;
}
main ()
{
(void) printf("Setting terminate() in main() ...\n");
set_terminate(main_terminate_handler);
pthread_t thread;
pthread_addr_t status;
if (pthread_create(&thread, pthread_attr_default, work, 0) < 0)
perror("pthread_create"), exit(1);
sleep(1);
(void) printf("throwing an exception in main() ...\n");
throw X();
(void) printf("Exiting main() ...\n");
return 0;
}
% cxx a.C -lpthreads -lc_r -lmach
% ./a.out
Setting terminate() in main() ...
Setting terminate() in a thread ...
throwing an exception in main() ...
exiting via terminate_handler() set in thread ...
script done on Mon Oct 31 08:43:57 1994
next reply other threads:[~1994-11-01 4:02 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
1994-11-01 4:02 Mr Mike James Lijewski [this message]
1994-11-02 16:13 ` bug with DEC C++ exceptions and Pthreads Tom Carlson
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox