]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blame - db/sig.c
xfsprogs: Release v6.7.0
[thirdparty/xfsprogs-dev.git] / db / sig.c
CommitLineData
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
11static int gotintr;
12static sigset_t intrset;
13
14static void
15interrupt(int sig, siginfo_t *info, void *uc)
16{
17 gotintr = 1;
18}
19
20void
21blockint(void)
22{
23 sigprocmask(SIG_BLOCK, &intrset, NULL);
24}
25
26void
27clearint(void)
28{
29 gotintr = 0;
30}
31
32void
33init_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
44int
45seenint(void)
46{
47 return gotintr;
48}
49
50void
51unblockint(void)
52{
53 sigprocmask(SIG_UNBLOCK, &intrset, NULL);
54}