1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//! Ctrl-C handling for the one-shot scan commands.
//!
//! A scan commits per batch and checks its [`ScanCancel`] token once per file, so tripping the
//! token stops it cleanly: completed files stay committed, the stale-file purge is skipped (an
//! unscanned file is never mistaken for a deleted one), and the store lock is released by the
//! normal drop path. Killing the process instead would also be crash-safe, but it skips the
//! summary and leaves the lock sidecar behind until the OS reclaims the flock.
//!
//! The first Ctrl-C requests that clean stop; a second one means the user will not wait, so it
//! exits immediately with the conventional `130`.
use crateScanCancel;
use INTERRUPTED;
/// Install the Ctrl-C handler and return the token it trips. The handler lives on a detached
/// thread for the rest of the process; this returns only once the signal is registered, so an
/// interrupt arriving right after the call is never lost to the default (immediate-kill) action.