Skip to content

Commit

Permalink
allow signal handling by the GAP kernel to be disabled for embedding …
Browse files Browse the repository at this point in the history
…in other applications
  • Loading branch information
embray committed Jan 7, 2019
1 parent 823bd43 commit 99fe35c
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 15 deletions.
7 changes: 4 additions & 3 deletions src/gap.c
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ int realmain( int argc, char * argv[] )
SetupGAPLocation(argc, argv);

/* initialize everything and read init.g which runs the GAP session */
InitializeGap( &argc, argv );
InitializeGap( &argc, argv, 1 );
if (!STATE(UserHasQUIT)) { /* maybe the user QUIT from the initial
read of init.g somehow*/
/* maybe compile in which case init.g got skipped */
Expand Down Expand Up @@ -1717,10 +1717,11 @@ static Obj POST_RESTORE;

void InitializeGap (
int * pargc,
char * argv [] )
char * argv [],
UInt handleSignals )
{
/* initialize the basic system and gasman */
InitSystem( *pargc, argv );
InitSystem( *pargc, argv, handleSignals );

/* Initialise memory -- have to do this here to make sure we are at top of C stack */
InitBags(SyStorMin,
Expand Down
5 changes: 3 additions & 2 deletions src/gap.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,12 @@ enum {

/****************************************************************************
**
*F InitializeGap( <argc>, <argv> ) . . . . . . . . . . . . . . . . init GAP
*F InitializeGap( <argc>, <argv>, <handleSignals> ) . . . . . . . init GAP
*/
extern void InitializeGap (
int * pargc,
char * argv [] );
char * argv [],
UInt handleSignals );


#endif // GAP_GAP_H
5 changes: 3 additions & 2 deletions src/libgap-api.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@
void GAP_Initialize(int argc,
char ** argv,
GAP_CallbackFunc markBagsCallback,
GAP_CallbackFunc errorCallback)
GAP_CallbackFunc errorCallback,
int handleSignals)
{
InitializeGap(&argc, argv);
InitializeGap(&argc, argv, handleSignals);
SetExtraMarkFuncBags(markBagsCallback);
STATE(JumpToCatchCallback) = errorCallback;

Expand Down
3 changes: 2 additions & 1 deletion src/libgap-api.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ typedef void (*GAP_CallbackFunc)(void);
extern void GAP_Initialize(int argc,
char ** argv,
GAP_CallbackFunc markBagsCallback,
GAP_CallbackFunc errorCallback);
GAP_CallbackFunc errorCallback,
int handleSignals);


////
Expand Down
7 changes: 5 additions & 2 deletions src/system.c
Original file line number Diff line number Diff line change
Expand Up @@ -1048,7 +1048,8 @@ UInt SyOriginalArgc;

void InitSystem (
Int argc,
Char * argv [] )
Char * argv [],
UInt handleSignals )
{
Char * *ptrlist;
UInt i; /* loop variable */
Expand Down Expand Up @@ -1105,7 +1106,9 @@ void InitSystem (
rl_initialize ();
#endif

SyInstallAnswerIntr();
if (handleSignals) {
SyInstallAnswerIntr();
}

#if defined(SYS_DEFAULT_PATHS)
SySetGapRootPath( SYS_DEFAULT_PATHS );
Expand Down
11 changes: 6 additions & 5 deletions src/system.h
Original file line number Diff line number Diff line change
Expand Up @@ -510,18 +510,19 @@ Int RegisterSyLongjmpObserver(voidfunc);

/****************************************************************************
**
*F InitSystem( <argc>, <argv> ) . . . . . . . . . initialize system package
*F InitSystem( <argc>, <argv>, <handleSignals> ) . initialize system package
**
** 'InitSystem' is called very early during the initialization from 'main'.
** It is passed the command line array <argc>, <argv> to look for options.
**
** For UNIX it initializes the default files 'stdin', 'stdout' and 'stderr',
** installs the handler 'syAnswerIntr' to answer the user interrupts
** '<ctr>-C', scans the command line for options, sets up the GAP root paths,
** locates the '.gaprc' file (if any), and more.
** and if handleSignals is non-zero installs the handler 'syAnswerIntr' to
** answer the user interrupts '<ctr>-C', scans the command line for options,
** sets up the GAP root paths, locates the '.gaprc' file (if any), and more.
*/
extern void InitSystem (
Int argc,
Char * argv [] );
Char * argv [],
UInt handleSignals );

#endif // GAP_SYSTEM_H

0 comments on commit 99fe35c

Please sign in to comment.