{"record":{"id":"989eb12c9eaf48ee","repo":"getzola/zola","slug":"error-setting-ctrl-c-handler","errorCode":null,"errorMessage":"Error setting Ctrl-C handler","messagePattern":"Error setting Ctrl-C handler","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/serve.rs","lineNumber":696,"sourceCode":"    log::info!(\n        \"Listening for changes in {}{}{{{}}}\",\n        root_dir.display(),\n        MAIN_SEPARATOR,\n        watch_list\n    );\n\n    let preserve_dotfiles_in_output = site.config.preserve_dotfiles_in_output;\n\n    log::info!(\"Press Ctrl+C to stop\\n\");\n    // Clean the output folder on ctrl+C\n    ctrlc::set_handler(move || {\n        match clean_site_output_folder(&output_path, preserve_dotfiles_in_output) {\n            Ok(()) => (),\n            Err(e) => log::error!(\"Errored while cleaning output folder: {e}\"),\n        }\n        ::std::process::exit(0);\n    })\n    .expect(\"Error setting Ctrl-C handler\");\n\n    let reload_sass = |site: &Site, paths: &Vec<&PathBuf>| {\n        let combined_paths =\n            paths.iter().map(|p| p.display().to_string()).collect::<Vec<String>>().join(\", \");\n        log::info!(\"Sass file(s) changed {combined_paths}\");\n        rebuild_done_handling(\n            &broadcaster,\n            compile_sass(&site.base_path, &site.output_path),\n            &site.sass_path.to_string_lossy(),\n        );\n    };\n\n    let reload_templates = |site: &mut Site| {\n        rebuild_done_handling(\n            &broadcaster,\n            site.reload_templates(),\n            &site.templates_path.to_string_lossy(),\n        );","sourceCodeStart":678,"sourceCodeEnd":714,"githubUrl":"https://github.com/getzola/zola/blob/61d30828217957120309db657950224edf9707e2/src/cmd/serve.rs#L678-L714","documentation":"serve() registers a ctrlc handler that cleans the site output folder when the user presses Ctrl+C, then calls .expect(...). The expect fires when the ctrlc crate fails to install the signal handler — typically because the OS disallows it for this process (restricted sandbox/container without SIGINT registration rights) or the platform is unsupported. Without the handler, Ctrl+C will terminate the process but skip the output-folder cleanup.","triggerScenarios":"Thrown at src/cmd/serve.rs:696 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Run the server outside sandboxes/containers that block signal handler registration","Degrade gracefully: log a warning and continue serving even if cleanup-on-exit cannot be installed","Clean the output folder on next startup instead of relying on exit-time cleanup"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"61d30828217957120309db657950224edf9707e2","analyzedAt":"2026-09-03T14:39:09.727Z","contentChangedAt":"2026-09-03T14:39:09.727Z","schemaVersion":2},"datasetVersion":"2026-09-10T17:17:09.494Z"}