1
0
mirror of https://github.com/simh/simh.git synced 2026-05-15 17:59:58 +00:00

SCP: Add SIM_PROCESS_PID built-in variable

- SIM_PROCESS_PID is potentially useful in simulator scripts to provide
  a currently unique value.
This commit is contained in:
Mark Pizzolato
2026-04-05 20:05:08 -10:00
parent 72b7d03184
commit 692dcd3796

7
scp.c
View File

@@ -1812,7 +1812,7 @@ static const char simh_help2[] =
" %%SIM_GIT_COMMIT_TIME%%, %%SIM_ARCHIVE_GIT_COMMIT_ID%%,\n"
" %%SIM_ARCHIVE_GIT_COMMIT_TIME%%, %%SIM_RUNLIMIT%%, %%SIM_RUNLIMIT_UNITS%%,\n"
" %%SIM_HOST_CORE_COUNT%%, %%SIM_HOST_MAX_THREADS%%,\n"
" %%SIM_ETHERNET_CAPABILITIES%%\n\n"
" %%SIM_ETHERNET_CAPABILITIES%%, %%SIM_PROCESS_PID%%\n\n"
"+Token %%0 expands to the command file name.\n"
"+Token %%n (n being a single digit) expands to the n'th argument\n"
"+Token %%* expands to the whole set of arguments (%%1 ... %%9)\n\n"
@@ -1884,6 +1884,7 @@ static const char simh_help2[] =
"++%%SIM_VERSION_MODE%% The release mode (Current, Alpha, Beta)\n"
"++%%SIM_GIT_COMMIT_ID%% The git commit id of the current build\n"
"++%%SIM_GIT_COMMIT_TIME%% The git commit time of the current build\n"
"++%%SIM_PROCESS_PID%% The process id of the running simulator\n"
"++%%SIM_RUNLIMIT%% The current execution limit defined\n"
"++%%SIM_RUNLIMIT_UNITS%% The units of the SIM_RUNLIMIT value\n"
"++++++++ (instructions, cycles or time)\n"
@@ -5117,6 +5118,10 @@ if (!ap) { /* no environment variable found? */
sprintf (rbuf, "%s", sim_error_text (stat));
ap = rbuf;
}
else if (!strcmp ("SIM_PROCESS_PID", gbuf)) {
sprintf (rbuf, "%u", (uint32)(getpid ()));
ap = rbuf;
}
else if (!strcmp ("SIM_VERIFY", gbuf)) {
sprintf (rbuf, "%s", sim_do_echo ? "-V" : "");
ap = rbuf;