//----------------------------------------------------------------------------- // signal-wait.h //----------------------------------------------------------------------------- #include #include #include #include #include #include #ifdef __has_include #if __has_include() #include #endif // __has_include #endif // __has_include() #ifdef __has_include #if __has_include() #include #endif // __has_include #endif // __has_include() //----------------------------------------------------------------------------- #ifdef __has_include #if __has_include() void usuario() { signal(SIGUSR1, SIG_IGN); boost::fibers::fiber t([] { raise(SIGUSR1); }); t.join(); } #endif // __has_include #endif // __has_include() //----------------------------------------------------------------------------- #ifdef __has_include #if __has_include() void hibrida() { pid_t parent = getpid(); signal(SIGUSR1, SIG_IGN); tbb::task_group tg; tg.run([&] { kill(parent, SIGUSR1); }); tg.wait(); } #endif // __has_include #endif // __has_include() //----------------------------------------------------------------------------- void nucleo() { pthread_t parent = pthread_self(); signal(SIGUSR1, SIG_IGN); std::thread t([&] { pthread_kill(parent, SIGUSR1); }); t.join(); } //----------------------------------------------------------------------------- void proceso() { pid_t parent = getpid(); if (fork()) { signal(SIGUSR1, SIG_IGN); wait(nullptr); } else { kill(parent, SIGUSR1); exit(0); } } //-----------------------------------------------------------------------------