X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=AcessNative%2Facesskernel_src%2Fthreads.c;h=661d584b4ad32a6ea605efa55f58cac57a517249;hb=a01b96ccf4ec884e5b894d08a819a37ea3f5f749;hp=ecc9f3315768f356dedb2444489e5c06c09d21e9;hpb=9d234f984c149fcc6b1f5aab21a0ca227c060e32;p=tpg%2Facess2.git diff --git a/AcessNative/acesskernel_src/threads.c b/AcessNative/acesskernel_src/threads.c index ecc9f331..661d584b 100644 --- a/AcessNative/acesskernel_src/threads.c +++ b/AcessNative/acesskernel_src/threads.c @@ -10,6 +10,8 @@ #include #include #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 #include #include @@ -19,7 +21,8 @@ #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 === @@ -264,13 +267,34 @@ int Threads_Fork(void) { 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 // -------------------------------------------------------------------- @@ -335,8 +359,8 @@ Uint32 Threads_WaitEvents(Uint32 Mask) 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);