{"record":{"id":"f79ac3d49107bd63","repo":"tokio-rs/tokio","slug":"there-is-no-signal-driver-running-must-be-called","errorCode":null,"errorMessage":"there is no signal driver running, must be called from the context of Tokio runtime","messagePattern":"there is no signal driver running, must be called from the context of Tokio runtime","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"tokio/src/runtime/driver.rs","lineNumber":103,"sourceCode":"\n        self.io.unpark();\n    }\n\n    cfg_io_driver! {\n        #[track_caller]\n        pub(crate) fn io(&self) -> &crate::runtime::io::Handle {\n            self.io\n                .as_ref()\n                .expect(\"A Tokio 1.x context was found, but IO is disabled. Call `enable_io` on the runtime builder to enable IO.\")\n        }\n    }\n\n    cfg_signal_internal_and_unix! {\n        #[track_caller]\n        pub(crate) fn signal(&self) -> &crate::runtime::signal::Handle {\n            self.signal\n                .as_ref()\n                .expect(\"there is no signal driver running, must be called from the context of Tokio runtime\")\n        }\n    }\n\n    cfg_time! {\n        /// Returns a reference to the time driver handle.\n        ///\n        /// Panics if no time driver is present.\n        #[track_caller]\n        pub(crate) fn time(&self) -> &crate::runtime::time::Handle {\n            self.time\n                .as_ref()\n                .expect(\"A Tokio 1.x context was found, but timers are disabled. Call `enable_time` on the runtime builder to enable timers.\")\n        }\n\n        #[cfg(tokio_unstable)]\n        pub(crate) fn with_time<F, R>(&self, f: F) -> R\n        where\n            F: FnOnce(Option<&crate::runtime::time::Handle>) -> R,","sourceCodeStart":85,"sourceCodeEnd":121,"githubUrl":"https://github.com/tokio-rs/tokio/blob/625954f365727668cb02d04172b34f1149637728/tokio/src/runtime/driver.rs#L85-L121","documentation":"Driver::signal() calls .expect(...) when self.signal is None — the runtime has no signal driver. Signal APIs (ctrl_c, unix::signal) require the signal driver, which is only enabled with enable_all or on platforms with cfg_signal_internal_and_unix.","triggerScenarios":"Calling signal APIs on a runtime built without enable_io (the signal driver depends on the I/O driver) or on a platform/configuration where cfg_signal_internal_and_unix is off.","commonSituations":"Builder with only enable_time(); calling ctrl_c from a manually-built current-thread runtime that skipped enable_all; target without Unix signal support.","solutions":["Use .enable_all() on the Builder so the signal driver is created.","On non-Unix/non-supported targets, avoid signal APIs and handle shutdown differently.","Ensure signal calls originate from within the runtime context (enter()/block_on).","Verify cfg_signal_internal_and_unix is active for your target."],"exampleFix":"// before\nlet rt = Builder::new_current_thread().build()?;\nrt.block_on(async { signal::ctrl_c().await }); // panics\n// after\nlet rt = Builder::new_current_thread().enable_all().build()?;\nrt.block_on(async { signal::ctrl_c().await });","handlingStrategy":"validation","validationCode":"// Ensure the signal driver is present by enabling all drivers:\nlet rt = tokio::runtime::Builder::new_current_thread()\n    .enable_all() // includes signal driver on Unix\n    .build()?;","typeGuard":null,"tryCatchPattern":"// Panic in macro path; manual build lets you handle:\nmatch Builder::new_current_thread().enable_all().build() {\n    Ok(rt) => rt.block_on(async { signal::ctrl_c().await }),\n    Err(e) => { eprintln!(\"no signal driver: {e}\"); std::process::exit(1); }\n}","preventionTips":["Use enable_all() so the signal driver runs.","Confirm cfg_signal_internal_and_unix for your target.","Call signal APIs only within runtime context."],"tags":["signal","signal-driver","runtime","builder","panic","configuration"],"backgroundTag":null,"analyzedSha":"625954f365727668cb02d04172b34f1149637728","analyzedAt":"2026-08-11T17:46:45.378Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}