#include <acess.h>
#include <mutex.h>
#include "../../KernelLand/Kernel/include/semaphore.h"
+typedef signed long long int time_t;
+#include "../../Usermode/Libraries/ld-acess.so_src/include_exp/acess/syscall_types.h"
#include <rwlock.h>
#include <events.h>
#include <threads_int.h>
#define THREAD_EVENT_WAKEUP 0x80000000
// === IMPORTS ===
-void VFS_CloneHandleList(int PID);
+extern void VFS_CloneHandleList(int PID);
+extern void VFS_CloneHandlesFromList(int PID, int nFD, int FDs[]);
// === STRUCTURES ===
// === PROTOTYPES ===
{
tThread *thread = Threads_CloneTCB(gpCurrentThread);
thread->PID = thread->TID;
+
// Duplicate the VFS handles (and nodes) from vfs_handle.c
-
VFS_CloneHandleList(thread->PID);
return thread->PID;
}
+int Threads_Spawn(int nFD, int FDs[], struct s_sys_spawninfo *info)
+{
+ tThread *thread = Threads_CloneTCB(gpCurrentThread);
+ thread->PID = thread->TID;
+ if( info )
+ {
+ // TODO: PGID?
+ //if( info->flags & SPAWNFLAG_NEWPGID )
+ // thread->PGID = thread->PID;
+ if( info->gid && thread->UID == 0 )
+ thread->GID = info->gid;
+ if( info->uid && thread->UID == 0 ) // last because ->UID is used above
+ thread->UID = info->uid;
+ }
+
+ VFS_CloneHandlesFromList(thread->PID, nFD, FDs);
+
+ Log_Debug("Threads", "_spawn: %i", thread->PID);
+ return thread->PID;
+}
+
// --------------------------------------------------------------------
// Mutexes
// --------------------------------------------------------------------
void Threads_PostEvent(tThread *Thread, Uint32 Events)
{
Thread->Events |= Events;
- Log_Debug("Threads", "Trigger event %x (->Events = %p) on %p", Events, Thread->Events, Thread);
-
+// Log_Debug("Threads", "Trigger event %x (->Events = %p) on %p", Events, Thread->Events, Thread);
+
if( Events == 0 || Thread->WaitMask & Events ) {
Threads_Glue_SemSignal( Thread->EventSem, 1 );
// Log_Debug("Threads", "Waking %p(%i %s)", Thread, Thread->TID, Thread->ThreadName);