From 7891fef3d5106411a62837b85f5c47c6a389c573 Mon Sep 17 00:00:00 2001 From: "W. Eric Norum" Date: Wed, 21 Sep 2005 14:08:32 +0000 Subject: [PATCH] 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()). --- src/RTEMS/base/rtems_init.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/RTEMS/base/rtems_init.c b/src/RTEMS/base/rtems_init.c index 3811eb396..e5110e62d 100644 --- a/src/RTEMS/base/rtems_init.c +++ b/src/RTEMS/base/rtems_init.c @@ -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); }