diff --git a/src/ca/access.cpp b/src/ca/access.cpp index 257489b7f..3826e2a46 100644 --- a/src/ca/access.cpp +++ b/src/ca/access.cpp @@ -23,6 +23,7 @@ #include #include +#include #define epicsAssertAuthor "Jeff Hill johill@lanl.gov" @@ -125,7 +126,7 @@ const char * ca_message_text [] static epicsThreadOnceId caClientContextIdOnce = EPICS_THREAD_ONCE_INIT; -extern "C" void ca_client_exit_handler () +extern "C" void ca_client_exit_handler (void *) { if ( caClientContextId ) { epicsThreadPrivateDelete ( caClientContextId ); @@ -138,7 +139,7 @@ extern "C" void ca_init_client_context ( void * ) { caClientContextId = epicsThreadPrivateCreate (); if ( caClientContextId ) { - atexit ( ca_client_exit_handler ); + epicsAtExit ( ca_client_exit_handler,0 ); } } diff --git a/src/ca/ca_client_context.cpp b/src/ca/ca_client_context.cpp index 35e9c9f2f..5a25de0d0 100644 --- a/src/ca/ca_client_context.cpp +++ b/src/ca/ca_client_context.cpp @@ -30,6 +30,7 @@ #include #include +#include "epicsExit.h" #define epicsExportSharedSymbols #include "iocinf.h" @@ -40,7 +41,7 @@ epicsShareDef epicsThreadPrivateId caClientCallbackThreadId; static epicsThreadOnceId cacOnce = EPICS_THREAD_ONCE_INIT; -extern "C" void cacExitHandler () +extern "C" void cacExitHandler (void *) { epicsThreadPrivateDelete ( caClientCallbackThreadId ); } @@ -50,7 +51,7 @@ extern "C" void cacOnceFunc ( void * ) { caClientCallbackThreadId = epicsThreadPrivateCreate (); assert ( caClientCallbackThreadId ); - atexit ( cacExitHandler ); + epicsAtExit ( cacExitHandler,0 ); } extern epicsThreadPrivateId caClientContextId; diff --git a/src/makeBaseApp/top/exampleApp/src/_APPNAME_Main.cpp b/src/makeBaseApp/top/exampleApp/src/_APPNAME_Main.cpp index 319244890..ae0ecb68a 100644 --- a/src/makeBaseApp/top/exampleApp/src/_APPNAME_Main.cpp +++ b/src/makeBaseApp/top/exampleApp/src/_APPNAME_Main.cpp @@ -7,6 +7,7 @@ #include #include +#include "epicsExit.h" #include "epicsThread.h" #include "iocsh.h" @@ -17,5 +18,6 @@ int main(int argc,char *argv[]) epicsThreadSleep(.2); } iocsh(NULL); + epicsExit(0); return(0); } diff --git a/src/softIoc/softMain.cpp b/src/softIoc/softMain.cpp index b476f00c7..b35957a18 100644 --- a/src/softIoc/softMain.cpp +++ b/src/softIoc/softMain.cpp @@ -57,6 +57,7 @@ #include "registryFunction.h" #include "epicsThread.h" +#include "epicsExit.h" #include "dbStaticLib.h" #include "subRecord.h" #include "dbAccess.h" @@ -74,7 +75,7 @@ const char *base_dbd = DBD_FILE(EPICS_BASE); static void exitSubroutine(subRecord *precord) { - exit((precord->a == 0.0) ? EXIT_SUCCESS : EXIT_FAILURE); + epicsExit((precord->a == 0.0) ? EXIT_SUCCESS : EXIT_FAILURE); } static void usage(int status) { @@ -83,7 +84,7 @@ static void usage(int status) { puts("\t[st.cmd]"); puts("Compiled-in default path to softIoc.dbd is:"); printf("\t%s\n", base_dbd); - exit(status); + epicsExit(status); } @@ -115,7 +116,7 @@ int main(int argc, char *argv[]) } if (dbLoadDatabase(dbd_file, NULL, NULL)) { - exit(EXIT_FAILURE); + epicsExit(EXIT_FAILURE); } softIoc_registerRecordDeviceDriver(pdbbase); @@ -131,7 +132,7 @@ int main(int argc, char *argv[]) case 'd': if (dbLoadRecords(*++argv, macros)) { - exit(EXIT_FAILURE); + epicsExit(EXIT_FAILURE); } loadedDb = 1; --argc; @@ -187,7 +188,7 @@ int main(int argc, char *argv[]) /* run user's startup script */ if (argc>0) { - if (iocsh(*argv)) exit(EXIT_FAILURE); + if (iocsh(*argv)) epicsExit(EXIT_FAILURE); epicsThreadSleep(0.2); loadedDb = 1; /* Give it the benefit of the doubt... */ } @@ -203,5 +204,7 @@ int main(int argc, char *argv[]) usage(EXIT_FAILURE); } } - return EXIT_SUCCESS; + epicsExit( EXIT_SUCCESS); + /*Note that the following statement will never be executed*/ + return 0; }