From e431a972ad72aee6e0eb43cf2eee26882a4a93a7 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Fri, 27 Oct 2023 09:26:58 -0400 Subject: [PATCH] Stop processing commands when "quit" is found instead of crashing. When using the library interface for processing commands, the "quit" command will terminate the application. Instead we intercept and just stop processing the command buffer and print a suitable message. Long-term, we perhaps may want to add a "QuitException" and throw that. --- src/library.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/library.cpp b/src/library.cpp index 7b0d8ef91b..9d542f86ae 100644 --- a/src/library.cpp +++ b/src/library.cpp @@ -702,6 +702,13 @@ void lammps_commands_string(void *handle, const char *str) continue; } } + // stop processing when quit command is found + if (words.size() && (words[0] == "quit")) { + if (lmp->comm->me == 0) + utils::logmesg(lmp, "Encountered a 'quit' command. Stopping ...\n"); + break; + } + lmp->input->one(cmd.c_str()); } }