1- use std:: env:: { self , args} ;
2- use std:: ffi:: CString ;
3- use std:: fs:: { create_dir_all, read_dir, remove_file} ;
4- use std:: io:: { self , IsTerminal , stderr, stdin} ;
5- use std:: path:: { Path , PathBuf } ;
6-
7- use std:: process:: { Command , exit} ;
8- use std:: sync:: { LazyLock , OnceLock } ;
9- use std:: thread;
10- use std:: time:: { Duration , SystemTime , UNIX_EPOCH } ;
11-
12- mod args;
13- mod config;
14- mod error;
15- mod install_progress;
16- mod lang;
17- mod path_completions;
18- mod pb;
19- mod subcommand;
20- mod table;
21- mod tui;
22- mod utils;
23-
1+ use crate :: config:: Config ;
2+ use crate :: error:: Chain ;
3+ use crate :: install_progress:: osc94_progress;
4+ use crate :: subcommand:: * ;
245use args:: { CliExecuter , OhManagerAilurus } ;
256use clap:: builder:: FalseyValueParser ;
267use clap:: { ArgAction , ArgMatches , Args , ColorChoice , CommandFactory , FromArgMatches , arg} ;
@@ -30,13 +11,25 @@ use error::OutputError;
3011use i18n_embed:: { DesktopLanguageRequester , Localizer } ;
3112use lang:: LANGUAGE_LOADER ;
3213use oma_console:: OmaLayer ;
14+ use oma_console:: console;
3315use oma_console:: print:: { OmaColorFormat , termbg} ;
3416use oma_console:: writer:: { MessageType , Writer , writeln_inner} ;
3517use oma_pm:: apt:: AptConfig ;
3618use oma_utils:: dbus:: { create_dbus_connection, get_another_oma_status} ;
3719use oma_utils:: { OsRelease , is_termux} ;
3820use reqwest:: Client ;
39- use rustix:: stdio:: stdout;
21+ use signal_hook:: consts:: { SIGINT , SIGTERM } ;
22+ use signal_hook:: iterator:: Signals ;
23+ use std:: env:: { self , args} ;
24+ use std:: ffi:: CString ;
25+ use std:: fs:: { create_dir_all, read_dir, remove_file} ;
26+ use std:: io:: { self , IsTerminal , stderr, stdin, stdout} ;
27+ use std:: path:: { Path , PathBuf } ;
28+ use std:: process:: { Command , exit} ;
29+ use std:: sync:: atomic:: { AtomicBool , Ordering } ;
30+ use std:: sync:: { LazyLock , OnceLock } ;
31+ use std:: thread;
32+ use std:: time:: { Duration , SystemTime , UNIX_EPOCH } ;
4033use subcommand:: utils:: { LockError , is_terminal} ;
4134use tokio:: runtime:: Runtime ;
4235use tracing:: { debug, error, info, warn} ;
@@ -47,14 +40,17 @@ use tracing_subscriber::{EnvFilter, Layer, fmt};
4740use tui:: Tui ;
4841use utils:: { is_root, is_ssh_from_loginctl} ;
4942
50- use std:: sync:: atomic:: { AtomicBool , Ordering } ;
51-
52- use oma_console:: console;
53-
54- use crate :: config:: Config ;
55- use crate :: error:: Chain ;
56- use crate :: install_progress:: osc94_progress;
57- use crate :: subcommand:: * ;
43+ mod args;
44+ mod config;
45+ mod error;
46+ mod install_progress;
47+ mod lang;
48+ mod path_completions;
49+ mod pb;
50+ mod subcommand;
51+ mod table;
52+ mod tui;
53+ mod utils;
5854
5955static NOT_DISPLAY_ABORT : AtomicBool = AtomicBool :: new ( false ) ;
6056static LOCKED : AtomicBool = AtomicBool :: new ( false ) ;
@@ -172,7 +168,12 @@ fn main() {
172168 . completer ( "oma" )
173169 . complete ( ) ;
174170
175- ctrlc:: set_handler ( single_handler) . expect ( "oma could not initialize SIGINT handler." ) ;
171+ thread:: spawn ( || {
172+ let mut sigs = Signals :: new ( [ SIGTERM , SIGINT ] ) . expect ( "Failed to set signal handler" ) ;
173+ for _ in & mut sigs {
174+ single_handler ( ) ;
175+ }
176+ } ) ;
176177
177178 // 要适配额外的插件子命令,所以这里要保留 matches
178179 let ( matches, oma) = parse_args ( ) ;
0 commit comments