Skip to content

Commit 56f358d

Browse files
committed
Add comment explaining signal handling in multiple engine threads
Signed-off-by: Adam Glustein <[email protected]>
1 parent 052a0f7 commit 56f358d

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

cpp/csp/engine/RootEngine.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,18 @@ namespace csp
1212
{
1313

1414
static volatile int g_SIGNAL_COUNT = 0;
15+
/*
16+
The signal count variable is maintained to ensure that multiple engine threads shutdown properly.
17+
18+
An interrupt should cause all running engines to stop, but should not affect future runs in the same process.
19+
Thus, each root engine keeps track of the signal count when its created. When an interrupt occurs, one engine thread
20+
handles the interrupt by incrementing the count. Then, all other root engines detect the signal by comparing their
21+
initial count to the current count.
22+
23+
Future runs after the interrupt remain unaffected since they are initialized with the updated signal count, and will
24+
only consider themselves "interupted" if another signal is received during their execution.
25+
*/
26+
1527
static struct sigaction g_prevSIGTERMaction;
1628

1729
static void handle_SIGTERM( int signum )

0 commit comments

Comments
 (0)