{"record":{"id":"36d741220736a804","repo":"clockworklabs/SpacetimeDB","slug":"failed-to-install-ctrl-c-handler","errorCode":null,"errorMessage":"failed to install Ctrl+C handler","messagePattern":"failed to install Ctrl\\+C handler","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/standalone/src/subcommands/start.rs","lineNumber":288,"sourceCode":"        ))?;\n\n        let notify = Arc::new(tokio::sync::Notify::new());\n        let shutdown_notify = notify.clone();\n        tokio::select! {\n            _ = pg_server::start_pg(notify.clone(), ctx, tcp_pg) => {},\n            _ = axum::serve(tcp, service).with_graceful_shutdown(async move  {\n                shutdown_notify.notified().await;\n            }) => {},\n            _ = tokio::signal::ctrl_c() => {\n                println!(\"Shutting down servers...\");\n                notify.notify_waiters(); // Notify all tasks\n            }\n        }\n    } else {\n        log::warn!(\"PostgreSQL wire protocol server disabled\");\n        axum::serve(tcp, service)\n            .with_graceful_shutdown(async {\n                tokio::signal::ctrl_c().await.expect(\"failed to install Ctrl+C handler\");\n                log::info!(\"Shutting down server...\");\n            })\n            .await?;\n    }\n\n    Ok(())\n}\n\n/// Check if a port is available on the requested host for both IPv4 and IPv6.\n///\n/// On macOS (and some other systems), `localhost` can resolve to both IPv4 (127.0.0.1)\n/// and IPv6 (::1). If SpacetimeDB binds only to IPv4 but another service is using the\n/// same port on IPv6, browsers may connect to the wrong service depending on which\n/// address they try first.\n///\n/// This function checks both the requested IPv4 address and its IPv6 equivalent:\n/// - 127.0.0.1 -> also checks ::1\n/// - 0.0.0.0 -> also checks ::","sourceCodeStart":270,"sourceCodeEnd":306,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/524b4487d949b61a07d4f39c862d1290259dfd20/crates/standalone/src/subcommands/start.rs#L270-L306","documentation":"The standalone `start` command installs a graceful-shutdown hook with `tokio::signal::ctrl_c().await.expect(\"failed to install Ctrl+C handler\")` in the branch where the PostgreSQL wire-protocol server is disabled. Installation fails when the runtime/environment cannot register a SIGINT handler — restricted sandboxes (seccomp blocking signal syscalls), unusual init systems, or signal-capacity exhaustion.","triggerScenarios":"Running `spacetimedb start` with the pg wire server disabled inside a hardened container (seccomp/AppArmor profile denying sigaction), gVisor/Kata-style sandboxes, or process supervisors that block signal registration.","commonSituations":"Docker with a custom restrictive seccomp profile; sandboxed CI runners; multiple signal-hungry runtimes sharing one container.","solutions":["Run the binary in a signal-capable environment (default Docker profile, systemd, a normal terminal), or loosen the sandbox profile to allow signal syscalls.","Prefer driving shutdown through the documented graceful-shutdown path rather than relying on Ctrl+C in headless deployments.","Reproduce under `docker run` defaults to confirm the sandbox is the cause."],"exampleFix":"# before: hardened profile blocks signal setup and the server panics\ndocker run --security-opt seccomp=no-signals.json spacetimedb start --no-pg\n\n# after: default profile permits sigaction, ctrl_c() installs cleanly\ndocker run spacetimedb start --no-pg","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use default container seccomp profiles; don't strip signal-related syscalls (sigaction/signal).","Prefer supervisor-driven shutdown (SIGTERM via your init) over relying on Ctrl+C in dockerized servers.","When sandboxing is required, keep the pg wire server branch enabled or use the documented shutdown path."],"tags":["rust","spacetimedb-standalone","signals","ctrl-c","server","containers"],"backgroundTag":"signal-handler-install-failed","analyzedSha":"524b4487d949b61a07d4f39c862d1290259dfd20","analyzedAt":"2026-08-16T23:58:54.611Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}