Ensure that rtems_shutdown_executive() gets called even if the main

routine does not return but rather calls exit() either directly or
indirectly (through epicsExit()).
This commit is contained in:
W. Eric Norum
2005-09-21 14:08:32 +00:00
parent 3620fc6de2
commit 7891fef3d5
+11 -1
View File
@@ -456,6 +456,15 @@ const void *rtemsConfigArray[] = {
&rtems_bsdnet_config
};
/*
* Hook to ensure that BSP cleanup code gets run on exit
*/
static void
exitHandler(void)
{
rtems_shutdown_executive(0);
}
/*
* RTEMS Startup task
*/
@@ -585,8 +594,9 @@ Init (rtems_task_argument ignored)
iocshRegisterRTEMS ();
set_directory (argv[1]);
epicsEnvSet ("IOC_STARTUP_SCRIPT", argv[1]);
atexit(exitHandler);
i = main ((sizeof argv / sizeof argv[0]) - 1, argv);
printf ("***** IOC application terminating *****\n");
epicsThreadSleep(1.0);
rtems_shutdown_executive(0);
epicsExit(0);
}