getzola/zola · error
Error setting Ctrl-C handler
Error message
Error setting Ctrl-C handler
What it means
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.
Source
Thrown at src/cmd/serve.rs:696
log::info!(
"Listening for changes in {}{}{{{}}}",
root_dir.display(),
MAIN_SEPARATOR,
watch_list
);
let preserve_dotfiles_in_output = site.config.preserve_dotfiles_in_output;
log::info!("Press Ctrl+C to stop\n");
// Clean the output folder on ctrl+C
ctrlc::set_handler(move || {
match clean_site_output_folder(&output_path, preserve_dotfiles_in_output) {
Ok(()) => (),
Err(e) => log::error!("Errored while cleaning output folder: {e}"),
}
::std::process::exit(0);
})
.expect("Error setting Ctrl-C handler");
let reload_sass = |site: &Site, paths: &Vec<&PathBuf>| {
let combined_paths =
paths.iter().map(|p| p.display().to_string()).collect::<Vec<String>>().join(", ");
log::info!("Sass file(s) changed {combined_paths}");
rebuild_done_handling(
&broadcaster,
compile_sass(&site.base_path, &site.output_path),
&site.sass_path.to_string_lossy(),
);
};
let reload_templates = |site: &mut Site| {
rebuild_done_handling(
&broadcaster,
site.reload_templates(),
&site.templates_path.to_string_lossy(),
);View on GitHub (pinned to 61d3082821)
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
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at src/cmd/serve.rs:696 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of getzola/zola@61d3082821 (2026-09-03).
Data as JSON: /api/errors/989eb12c9eaf48ee.
Report an issue: GitHub.