Doing an upgrade to my custom file/folder asset handling functions and decided to resolve the problem I think O_CLOEXEC attempts to resolve with process/thread checks, process check was easy enough with but thread checking is proving a little more difficult, anyone know what function is the equivalent or am I just gonna have to accept "asset->thread != thread" as the best method on win32? For reference here's the unfinished function I'm using:
Code:
dint TestLassetAccess( LASSET *Lasset, ach const *action )
{
dint err = EACCES, pid = getpid();
SYNC *Sync = GetLassetSync(Lasset);
FILE *out = Sync->out;
thread_t thread;
if ( Lasset->pid != pid )
{
ECHO_ERROR( out, err );
fprintf( out, "File '%s' is assigned to process %d, process %d cannot %s it\n" );
return err;
}
#ifdef _WIN32
thread = GetCurrentThread();
if ( Lasset->thread != thread )
#else
thread = pthread_self();
if ( !pthread_equal( Lasset->thread, thread ) )
#endif
{
ECHO_ERROR( out, err );
fprintf( out, "File '%s' is assigned to thread %d, thread %d cannot %s it\n" );
return err;
}
return 0;
}