Local code intelligence for developers and AI agents. Connect code, docs and infrastructure in a persistent graph, with CBM Lens, MCP tools, agent integrations and change-aware test selection.
C aiderastclaude-codecode-analysiscode-intelligencecodexcursorcypherdeveloper-toolsgemini-cligraph-visualizationkilocodeknowledge-graphmcpmcp-servermodel-context-protocolopencodesqlitetree-sitterwindsurf
Prevent silent hangs on non-interactive stdin
Martin Vogelda7638c651d6
diff --git a/scripts/smoke-test.sh b/scripts/smoke-test.shindex 51a9559e9..683fbee53 100755--- a/scripts/smoke-test.sh+++ b/scripts/smoke-test.sh@@ -882,6 +882,17 @@ HOME="$DBL_HOME" "$BINARY" uninstall -y -n 2>&1 > /dev/null || trueecho "OK 9b-8: double uninstall doesn't crash"rm -rf "$DBL_HOME"+# 9b-9: Non-interactive update without --standard/--ui should fail cleanly (not hang)+if [ "$(uname -s)" != "MINGW64_NT" ] 2>/dev/null; then+ NONINT_OUT=$(echo "" | "$BINARY" update --dry-run 2>&1) || true+ if echo "$NONINT_OUT" | grep -qi 'terminal\|requires.*flag\|error'; then+ echo "OK 9b-9: non-interactive update fails with clear error"+ else+ # Dry-run may still complete if no variant prompt needed+ echo "OK 9b-9: non-interactive update handled gracefully"+ fi+fi+rm -rf "$FAKE_HOME" "$EMPTY_HOME"echo ""diff --git a/src/cli/cli.c b/src/cli/cli.cindex dbee30079..d99621932 100644--- a/src/cli/cli.c+++ b/src/cli/cli.c@@ -13,6 +13,7 @@#include <ctype.h>#ifndef _WIN32#include <signal.h>+#include <unistd.h>#endif#include "foundation/compat_fs.h"@@ -2172,6 +2173,14 @@ static bool prompt_yn(const char *question) {return false;}+ /* Non-interactive stdin: default to "no" to avoid hanging */+#ifndef _WIN32+ if (!isatty(fileno(stdin))) {+ fprintf(stderr, "error: interactive prompt requires a terminal. Use -y or -n flags.\n");+ return false;+ }+#endif+printf("%s (y/n): ", question);(void)fflush(stdout);@@ -2982,6 +2991,13 @@ int cbm_cmd_update(int argc, char **argv) {} else if (variant_flag == 2) {want_ui = true;} else {+#ifndef _WIN32+ if (!isatty(fileno(stdin))) {+ fprintf(stderr, "error: variant selection requires a terminal. "+ "Use --standard or --ui flag.\n");+ return 1;+ }+#endifprintf("Which binary variant do you want?\n");printf(" 1) standard — MCP server only\n");printf(" 2) ui — MCP server + embedded graph visualization\n");