From: Harald Fernengel Date: Sun, 26 Mar 2023 05:25:46 +0000 (+0200) Subject: Exit from interactive mode if input stream is bad (#491) X-Git-Tag: gguf-v0.4.0~1094 X-Git-Url: https://git.djapps.eu/?a=commitdiff_plain;h=33e35b8fe8f09adcac0632e9cece62e1dd629f7d;p=pkg%2Fggml%2Fsources%2Fllama.cpp Exit from interactive mode if input stream is bad (#491) Allow exiting the interactive prompt also with CTRL-D on Unix and CTRL-Z on Windows. --- diff --git a/examples/main/main.cpp b/examples/main/main.cpp index 9af8a740..e9478d54 100644 --- a/examples/main/main.cpp +++ b/examples/main/main.cpp @@ -450,7 +450,10 @@ int main(int argc, char ** argv) { std::string line; bool another_line = true; do { - std::getline(std::cin, line); + if (!std::getline(std::cin, line)) { + // input stream is bad or EOF received + return 0; + } if (line.empty() || line.back() != '\\') { another_line = false; } else {