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.
This commit is contained in:
Axel Kohlmeyer
2023-10-27 09:26:58 -04:00
parent 6b4a190820
commit e431a972ad

View File

@ -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());
}
}