X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Fmain.rs;h=f3d888bca37e6818e0e4db727a64792c014fbdf6;hb=e9d2908765c3970f5d2d9e70eeb6459e47b372da;hp=6cff9f152492058c156e7fb1cf48ccb4e3910f38;hpb=2121c2dcb70700695fa108b4fd1d6d8e5143d930;p=ldk-sample diff --git a/src/main.rs b/src/main.rs index 6cff9f1..f3d888b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -775,5 +775,28 @@ async fn start_ldk() { #[tokio::main] pub async fn main() { + #[cfg(not(target_os = "windows"))] + { + // Catch Ctrl-C with a dummy signal handler. + unsafe { + let mut new_action: libc::sigaction = core::mem::zeroed(); + let mut old_action: libc::sigaction = core::mem::zeroed(); + + extern "C" fn dummy_handler( + _: libc::c_int, _: *const libc::siginfo_t, _: *const libc::c_void, + ) { + } + + new_action.sa_sigaction = dummy_handler as libc::sighandler_t; + new_action.sa_flags = libc::SA_SIGINFO; + + libc::sigaction( + libc::SIGINT, + &new_action as *const libc::sigaction, + &mut old_action as *mut libc::sigaction, + ); + } + } + start_ldk().await; }