-}
-
-void PThreadEngine::Create(Thread* thread_to_init)
-{
- pthread_attr_t attribs;
- pthread_attr_init(&attribs);
- pthread_attr_setdetachstate(&attribs, PTHREAD_CREATE_JOINABLE);
- pthread_t* MyPThread = new pthread_t;
-
- /* Create a thread in a mutex. This prevents whacking the member value NewThread,
- * and also prevents recursive creation of threads by mistake (instead, the thread
- * will just deadlock itself)
- */
- Mutex(true);
-
- if (pthread_create(MyPThread, &attribs, PThreadEngine::Entry, (void*)this) != 0)
- {
- delete MyPThread;
- Mutex(false);
- throw CoreException("Unable to create new PThreadEngine: " + std::string(strerror(errno)));
- }
-
- pthread_attr_destroy(&attribs);
-
- NewThread = thread_to_init;
- NewThread->Creator = this;
- NewThread->Extend("pthread", MyPThread);
-
- /* Always unset a mutex if you set it */
- Mutex(false);
+ /* Recommended by nenolod, signal safety on a per-thread basis */
+ sigset_t set;
+ sigemptyset(&set);
+ sigaddset(&set, SIGPIPE);
+ pthread_sigmask(SIG_BLOCK, &set, NULL);