]>
Commit | Line | Data |
---|---|---|
959ef981 | 1 | // SPDX-License-Identifier: GPL-2.0 |
2bd0ea18 | 2 | /* |
da23017d NS |
3 | * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc. |
4 | * All Rights Reserved. | |
2bd0ea18 NS |
5 | */ |
6 | ||
6b803e5a | 7 | #include "libxfs.h" |
2bd0ea18 NS |
8 | #include <signal.h> |
9 | #include "sig.h" | |
10 | ||
11 | static int gotintr; | |
12 | static sigset_t intrset; | |
13 | ||
14 | static void | |
15 | interrupt(int sig, siginfo_t *info, void *uc) | |
16 | { | |
17 | gotintr = 1; | |
18 | } | |
19 | ||
20 | void | |
21 | blockint(void) | |
22 | { | |
23 | sigprocmask(SIG_BLOCK, &intrset, NULL); | |
24 | } | |
25 | ||
26 | void | |
27 | clearint(void) | |
28 | { | |
29 | gotintr = 0; | |
30 | } | |
31 | ||
32 | void | |
33 | init_sig(void) | |
34 | { | |
35 | struct sigaction sa; | |
36 | ||
37 | memset(&sa, 0, sizeof(sa)); | |
38 | sa.sa_sigaction = interrupt; | |
39 | sigaction(SIGINT, &sa, NULL); | |
40 | sigemptyset(&intrset); | |
41 | sigaddset(&intrset, SIGINT); | |
42 | } | |
43 | ||
44 | int | |
45 | seenint(void) | |
46 | { | |
47 | return gotintr; | |
48 | } | |
49 | ||
50 | void | |
51 | unblockint(void) | |
52 | { | |
53 | sigprocmask(SIG_UNBLOCK, &intrset, NULL); | |
54 | } |