BRL-CAD
#include "common.h"
#include <signal.h>
#include "bu/file.h"
#include "bu/log.h"
Include dependency graph for interrupt.c:

Go to the source code of this file.

Macros

#define _BU_MAX_SIGNUM   128
 

Typedefs

typedef void(* sig_t) (int)
 

Functions

HIDDEN int interrupt_suspend_signal (int signum)
 
HIDDEN int interrupt_restore_signal (int signum)
 
int bu_suspend_interrupts ()
 
int bu_restore_interrupts ()
 

Variables

volatile sig_atomic_t interrupt_defer_signal [_BU_MAX_SIGNUM]
 
volatile sig_atomic_t interrupt_signal_pending [_BU_MAX_SIGNUM]
 
volatile sig_t interrupt_signal_func [_BU_MAX_SIGNUM]
 

Detailed Description

Routines for managing signals. In particular, provide a common means to temporarily buffer processing a signal during critical write operations.

Definition in file interrupt.c.

Macro Definition Documentation

#define _BU_MAX_SIGNUM   128

Definition at line 50 of file interrupt.c.

Referenced by interrupt_restore_signal(), and interrupt_suspend_signal().

Typedef Documentation

typedef void(* sig_t) (int)

Definition at line 43 of file interrupt.c.

Function Documentation

HIDDEN int interrupt_suspend_signal ( int  signum)

Defer signal processing for critical sections.

Signal processing for a given 'signum' signal is put on hold until interrupt_restore_signal() is called. If a signal is received while suspended, it will be raised when/if the signal is restored.

Returns non-zero on error (with perror set if signal() failure). Returns 1 if already suspended. Returns 2 if signal failure.

This comment should be moved to bu/file.h if this HIDDEN function is publicly exposed.

Definition at line 115 of file interrupt.c.

References _BU_MAX_SIGNUM, BU_ASSERT, interrupt_defer_signal, interrupt_signal_func, and interrupt_signal_pending.

Referenced by bu_suspend_interrupts().

HIDDEN int interrupt_restore_signal ( int  signum)

Restore signal processing for a given suspended signal.

If a signal was raised since interrupt_suspend_signal() was called, the previously installed signal handler will be immediately called albeit only once even if multiple signals were received.

Returns non-zero on error (with perror set if signal() failure). Returns 1 if unexpected suspend state. Returns 2 if signal failure.

This comment should be moved to bu/file.h if this HIDDEN function is publicly exposed.

Definition at line 156 of file interrupt.c.

References _BU_MAX_SIGNUM, BU_ASSERT, interrupt_defer_signal, interrupt_signal_func, and interrupt_signal_pending.

Referenced by bu_restore_interrupts().

Variable Documentation

volatile sig_atomic_t interrupt_defer_signal[_BU_MAX_SIGNUM]
Initial value:
= {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
}

Definition at line 53 of file interrupt.c.

Referenced by interrupt_restore_signal(), and interrupt_suspend_signal().

volatile sig_atomic_t interrupt_signal_pending[_BU_MAX_SIGNUM]
Initial value:
= {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
}

Definition at line 65 of file interrupt.c.

Referenced by interrupt_restore_signal(), and interrupt_suspend_signal().

volatile sig_t interrupt_signal_func[_BU_MAX_SIGNUM]
Initial value:
= {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
}

Definition at line 77 of file interrupt.c.

Referenced by interrupt_restore_signal(), and interrupt_suspend_signal().