fork(1) download
#include <tbb/tbb.h>

#include <iostream>

tbb::atomic<bool> caused_exception; // we want to cause an exception only once

struct seh_exception {};

void sehExceptionTranslator(unsigned int code, struct _EXCEPTION_POINTERS *ep)
{
  throw seh_exception();
}

void causeSehException()
{
  // ensure that we have an exception translator even in sub_tasks
  _set_se_translator(sehExceptionTranslator);

  // cause the exception exactly once
  if (!caused_exception.compare_and_swap(true, false))
  {
    volatile int *pInt = 0x00000000;
    *pInt = 20;
  }
}

void causeSehExceptionInTbbThread()
{  
  tbb::parallel_for(0, 8, [&](int i)
  {    
    tbb::this_tbb_thread::sleep(tbb::tick_count::interval_t( 0.5 ));
    causeSehException();
  });
}

int main()
{
  caused_exception = false;

  _set_se_translator(sehExceptionTranslator);
  try
  {
    causeSehExceptionInTbbThread();
  }
  catch (seh_exception&) 
  {
    std::cout << "seh exception caught" << std::endl;
  }
}
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:1:21: fatal error: tbb/tbb.h: No such file or directory
 #include <tbb/tbb.h>
                     ^
compilation terminated.
stdout

Standard output is empty