<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
--></style>
</head>
<body class='hmmessage'>
Or should the userthreads version implement<br>itself and require user to call RTProcess.Fork()?<br><br>You know, we have this odd but ok/useful state:<br> Even though we support userthreads, every system<br> has pthreads. I still have to verify that all systems<br> have pthread_atfork, but I assume so.<br><br>Also funny thing btw, pthreads, userthreads, win32 threads,<br> the code will be highly shared.<br> They will call RegisterForkHandlers.<br> The fork handlers will be same or similar.<br> Specifically in ThreadPThread.c and ThreadPosix.c -- reinitialize.<br> For ThreadPosix that should achieve "don't switch to any preexisting thread",<br> which is equivalent to "kill all other threads".<br><br>implied question:<br> Call it AtFork or RegisterForkHandlers or ?<br><br><br>RTProcessC.c<br><br>typedef void (*ForkHandler)(void);<br><br>#ifndef _WIN32<br>#include <pthread.h><br>#include <errno.h><br>#include <unistd.h><br>#endif<br><br>/* NOTE: Even userthreads now depends<br> * on availability of pthreads.<br> * This can be fixed if need be.<br> */<br><br>int<br>RTProcess__RegisterForkHandlers(<br> ForkHandler prepare,<br> ForkHandler parent,<br> ForkHandler child)<br>{<br>#ifdef _WIN32<br> return 0;<br>#else<br> while (1)<br> {<br> int i = pthread_atfork(prepare, parent, child);<br> if (i != EAGAIN)<br> return i;<br> sleep(0);<br> }<br>#endif<br>}<br><br> </body>
</html>