BRL-CAD
Loading...
Searching...
No Matches
interrupt.h
Go to the documentation of this file.
1/* I N T E R R U P T . H
2 * BRL-CAD
3 *
4 * Copyright (c) 2004-2026 United States Government as represented by
5 * the U.S. Army Research Laboratory.
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public License
9 * version 2.1 as published by the Free Software Foundation.
10 *
11 * This library is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this file; see the file named COPYING for more
18 * information.
19 */
20
21#ifndef BU_INTERRUPT_H
22#define BU_INTERRUPT_H
23
24#include "common.h"
25
26/* signal.h is problematic on certain versions of Xcode. It uses but doesn't
27 * define NSIG. We do the include here with the workaround and reuse this
28 * header in BRL-CAD code that needs signal.h */
29#if defined(__APPLE__) && !defined(NSIG)
30# define NSIG 32
31#endif
32#ifdef __cplusplus
33#include <csignal>
34#else
35#include <signal.h>
36#endif
37
38#include "bu/defines.h"
39
40
42
43/** @addtogroup bu_env
44 *
45 * @brief Routines for managing signals.
46 *
47 * These routines provide a common means to temporarily disable and
48 * buffer signal processing during critical write operations.
49 *
50 */
51/** @{ */
52
53
54/**
55 * Defer signal processing and interrupts before critical sections.
56 *
57 * Signal processing for a variety of signals that would otherwise
58 * disrupt the logic of an application are put on hold until
59 * bu_interrupt_restore() is called.
60 *
61 * If an interrupt signal is received while suspended, it will be
62 * raised when/if interrupts are restored.
63 *
64 * Returns 0 on success.
65 * Returns non-zero on error (with perror set if signal() failure).
66 */
68
69
70/**
71 * Resume signal processing and interrupts after critical sections.
72 *
73 * If a signal was raised since bu_interrupt_suspend() was called,
74 * the previously installed signal handler will be immediately called
75 * albeit only once even if multiple signals were received.
76 *
77 * Returns 0 on success.
78 * Returns non-zero on error (with perror set if signal() failure).
79 */
81
82
83/** @} */
84
86
87#endif /* BU_INTERRUPT_H */
88
89/*
90 * Local Variables:
91 * mode: C
92 * tab-width: 8
93 * indent-tabs-mode: t
94 * c-file-style: "stroustrup"
95 * End:
96 * ex: shiftwidth=4 tabstop=8
97 */
Definition dvec.h:74
Header file for the BRL-CAD common definitions.
int bu_interrupt_suspend(void)
int bu_interrupt_restore(void)