RTEMS: don't fault when no startup script is provided

epicsRtemsFSImage=NULL is the documented "none is needed" case, and it
is the one initialize_local_filesystem() success path that leaves
argv[1] unset, so set_directory() reached strrchr(NULL, '/') and killed
the guest before main().  Same defect in the score/ and posix/ inits.
This commit is contained in:
Sang Woo Kim authored and Andrew Johnson committed 2026-10-21 20:27:26 -04:00
1 parent 8770f172fc
commit e64d981e8f
2 files changed
+16 -6

No files matched your search

+8 -3
View File
@@ -1251,8 +1251,13 @@ POSIX_Init ( void *argument __attribute__((unused)))
printf ("***** Preparing EPICS application *****\n");
iocshRegisterRTEMS ();
set_directory (argv[1]);
epicsEnvSet ("IOC_STARTUP_SCRIPT", argv[1]);
/* No startup script when the application declares that it needs no
* filesystem (epicsRtemsFSImage == NULL).
*/
if (argv[1] != NULL) {
set_directory (argv[1]);
epicsEnvSet ("IOC_STARTUP_SCRIPT", argv[1]);
}
atexit(exitHandler);
printf ("***** Starting EPICS application *****\n");
@@ -1270,7 +1275,7 @@ POSIX_Init ( void *argument __attribute__((unused)))
NULL);
#endif
result = main ((sizeof argv / sizeof argv[0]) - 1, argv);
result = main (argv[1] != NULL ? 2 : 1, argv);
printf ("***** IOC application terminating *****\n");
epicsThreadSleep(1.0);
epicsExit(result);
+8 -3
View File
@@ -681,11 +681,16 @@ Init (rtems_task_argument ignored)
*/
printf ("***** Preparing EPICS application *****\n");
iocshRegisterRTEMS ();
set_directory (argv[1]);
epicsEnvSet ("IOC_STARTUP_SCRIPT", argv[1]);
/* No startup script when the application declares that it needs no
* filesystem (epicsRtemsFSImage == NULL).
*/
if (argv[1] != NULL) {
set_directory (argv[1]);
epicsEnvSet ("IOC_STARTUP_SCRIPT", argv[1]);
}
atexit(exitHandler);
printf ("***** Starting EPICS application *****\n");
result = main ((sizeof argv / sizeof argv[0]) - 1, argv);
result = main (argv[1] != NULL ? 2 : 1, argv);
printf ("***** IOC application terminating *****\n");
epicsThreadSleep(1.0);
epicsExit(result);