From 603a880d8eefb8e49bd2baf4a5dfa04220def454 Mon Sep 17 00:00:00 2001 From: Marten Lohstroh Date: Fri, 22 Dec 2023 12:38:41 -0600 Subject: [PATCH 1/2] Adjustments to launch script --- .../federated/launcher/FedLauncherGenerator.java | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/core/src/main/java/org/lflang/federated/launcher/FedLauncherGenerator.java b/core/src/main/java/org/lflang/federated/launcher/FedLauncherGenerator.java index 6bcc5fde33..0a6ad73c64 100644 --- a/core/src/main/java/org/lflang/federated/launcher/FedLauncherGenerator.java +++ b/core/src/main/java/org/lflang/federated/launcher/FedLauncherGenerator.java @@ -178,26 +178,18 @@ public void doGenerate(List federates, RtiConfig rtiConfig) { .append("\n"); } } - if (host.equals("localhost") || host.equals("0.0.0.0")) { - // Local PID managements - shCode.append( - "echo \"#### Bringing the RTI back to foreground so it can receive Control-C.\"" + "\n"); - shCode.append("fg %1" + "\n"); - } // Wait for launched processes to finish shCode .append( String.join( "\n", - "echo \"RTI has exited. Wait for federates to exit.\"", - "# Wait for launched processes to finish.", - "# The errors are handled separately via trap.", + "EXITED_SUCCESSFULLY=true", + "wait $RTI || EXITED_SUCCESSFULLY=false", "for pid in \"${pids[@]}\"", "do", - " wait $pid || exit $?", + " wait $pid || EXITED_SUCCESSFULLY=false", "done", - "echo \"All done.\"", - "EXITED_SUCCESSFULLY=true")) + "echo \"All done.\"")) .append("\n"); // Create bin directory for the script. From bb6ea674b71eab361cd8d6980d97acd1e5557db1 Mon Sep 17 00:00:00 2001 From: Marten Lohstroh Date: Fri, 22 Dec 2023 17:27:42 -0600 Subject: [PATCH 2/2] Address comment --- .../org/lflang/federated/launcher/FedLauncherGenerator.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/org/lflang/federated/launcher/FedLauncherGenerator.java b/core/src/main/java/org/lflang/federated/launcher/FedLauncherGenerator.java index 0a6ad73c64..1331f1b8c3 100644 --- a/core/src/main/java/org/lflang/federated/launcher/FedLauncherGenerator.java +++ b/core/src/main/java/org/lflang/federated/launcher/FedLauncherGenerator.java @@ -187,7 +187,10 @@ public void doGenerate(List federates, RtiConfig rtiConfig) { "wait $RTI || EXITED_SUCCESSFULLY=false", "for pid in \"${pids[@]}\"", "do", - " wait $pid || EXITED_SUCCESSFULLY=false", + " wait $pid", + " if [ $? -ne 0 -a $? -ne 127 ]; then", + " EXITED_SUCCESSFULLY=false", + " fi", "done", "echo \"All done.\"")) .append("\n");