SCIP Doxygen Documentation
Loading...
Searching...
No Matches

Detailed Description

methods and datastructures for catching the user CTRL-C interrupt

Author
Tobias Achterberg

Definition in file interrupt.c.

#include <assert.h>
#include <sys/types.h>
#include <stdlib.h>
#include <signal.h>
#include "scip/def.h"
#include "scip/pub_message.h"
#include "blockmemshell/memory.h"
#include "scip/interrupt.h"

Go to the source code of this file.

Data Structures

struct  SCIP_Interrupt

Functions

static void interruptHandler (int signumsignum)
SCIP_RETCODE SCIPinterruptCreate (SCIP_INTERRUPT **interrupt)
void SCIPinterruptFree (SCIP_INTERRUPT **interrupt)
void SCIPinterruptCapture (SCIP_INTERRUPT *interrupt)
void SCIPinterruptRelease (SCIP_INTERRUPT *interrupt)
SCIP_Bool SCIPinterrupted (void)
SCIP_Bool SCIPterminated (void)
void SCIPtryTerminate (void)
void SCIPresetInterrupted (void)

Variables

static volatile int ninterrupts = 0
static volatile int nterms = 0

Function Documentation

◆ interruptHandler()

void interruptHandler ( int signum)
static

interrupt handler for CTRL-C interrupts

Parameters
signuminterrupt signal number

Definition at line 72 of file interrupt.c.

References interruptHandler(), ninterrupts, and SCIP_UNUSED.

Referenced by interruptHandler(), and SCIPinterruptCapture().

◆ SCIPinterruptCreate()

SCIP_RETCODE SCIPinterruptCreate ( SCIP_INTERRUPT ** interrupt)

creates a CTRL-C interrupt data

Parameters
interruptpointer to store the CTRL-C interrupt data

Definition at line 91 of file interrupt.c.

References assert(), BMSallocMemory, NULL, SCIP_ALLOC, SCIP_OKAY, and SCIPinterruptCreate().

Referenced by doScipCreate(), and SCIPinterruptCreate().

◆ SCIPinterruptFree()

void SCIPinterruptFree ( SCIP_INTERRUPT ** interrupt)

frees a CTRL-C interrupt data

Parameters
interruptpointer to the CTRL-C interrupt data

Definition at line 104 of file interrupt.c.

References assert(), BMSfreeMemory, NULL, and SCIPinterruptFree().

Referenced by SCIPfree(), and SCIPinterruptFree().

◆ SCIPinterruptCapture()

void SCIPinterruptCapture ( SCIP_INTERRUPT * interrupt)

captures the CTRL-C interrupt to call the SCIP's own interrupt handler

Parameters
interruptCTRL-C interrupt data

Definition at line 114 of file interrupt.c.

References assert(), interruptHandler(), ninterrupts, nterms, NULL, SCIP_Interrupt::nuses, SCIP_Interrupt::oldsigaction, and SCIPinterruptCapture().

Referenced by SCIPinterruptCapture(), SCIPpresolve(), SCIPsolve(), and SCIPsolveConcurrent().

◆ SCIPinterruptRelease()

void SCIPinterruptRelease ( SCIP_INTERRUPT * interrupt)

releases the CTRL-C interrupt and restores the old interrupt handler

Parameters
interruptCTRL-C interrupt data

Definition at line 144 of file interrupt.c.

References assert(), NULL, SCIP_Interrupt::nuses, SCIP_Interrupt::oldsigaction, and SCIPinterruptRelease().

Referenced by SCIPinterruptRelease(), SCIPpresolve(), SCIPsolve(), and SCIPsolveConcurrent().

◆ SCIPinterrupted()

SCIP_Bool SCIPinterrupted ( void )

returns whether the user interrupted by pressing CTRL-C

Definition at line 163 of file interrupt.c.

References ninterrupts, SCIP_Bool, and SCIPinterrupted().

Referenced by SCIPinterrupted(), SCIPpressedCtrlC(), and SCIPsolveIsStopped().

◆ SCIPterminated()

SCIP_Bool SCIPterminated ( void )

returns whether a process termination signal was received

returns whether the process has received a SIGTERM

Definition at line 171 of file interrupt.c.

References nterms, SCIP_Bool, and SCIPterminated().

Referenced by SCIPsolveIsStopped(), and SCIPterminated().

◆ SCIPtryTerminate()

void SCIPtryTerminate ( void )

sends a termination signal to all SCIP processes so that they try to terminate as soon as possible

Note
For terminating a specific SCIP process use SCIPinterruptSolve().

Definition at line 182 of file interrupt.c.

References nterms, and SCIPtryTerminate().

Referenced by handleSigterm(), and SCIPtryTerminate().

◆ SCIPresetInterrupted()

void SCIPresetInterrupted ( void )

resets the number of interrupts to 0

Definition at line 190 of file interrupt.c.

References ninterrupts, nterms, and SCIPresetInterrupted().

Referenced by SCIPresetInterrupted(), and SCIPsolveIsStopped().

Variable Documentation

◆ ninterrupts

volatile int ninterrupts = 0
static

static variable counting the number of CTRL-C interrupts

Definition at line 45 of file interrupt.c.

Referenced by interruptHandler(), SCIPinterruptCapture(), SCIPinterrupted(), and SCIPresetInterrupted().

◆ nterms

volatile int nterms = 0
static

static variable counting the number of times that the process received a SIGTERM signal

Definition at line 47 of file interrupt.c.

Referenced by SCIPinterruptCapture(), SCIPresetInterrupted(), SCIPterminated(), and SCIPtryTerminate().