Fixed stack changing in SYS_CLONE
authorJohn Hodge <[email protected]>
Sun, 27 Sep 2009 03:16:20 +0000 (11:16 +0800)
committerJohn Hodge <[email protected]>
Sun, 27 Sep 2009 03:16:20 +0000 (11:16 +0800)
Kernel/syscalls.c
Usermode/Applications/init_src/main.c

index e6d8ed3..492c33e 100644 (file)
@@ -58,7 +58,7 @@ void SyscallHandler(tSyscallRegs *Regs)
                // Call clone system call
                ret = Proc_Clone(&err, Regs->Arg1);
                // Change user stack if requested
-               if(ret == 0 && Regs->Arg2)
+               if(ret == 0 && !(Regs->Arg2 & CLONE_VM))
                        Regs->StackPointer = Regs->Arg2;
                break;
        
index 55c4801..b205e3b 100644 (file)
@@ -22,14 +22,13 @@ int main(int argc, char *argv[])
        write(1, 13, "Hello, World!");
        
        tid = clone(CLONE_VM, 0);
+       __asm__ __volatile__("xchg %%bx, %%bx"::"a"(tid));
        if(tid == 0)
        {
                execve(DEFAULT_SHELL, NULL, NULL);
                for(;;) __asm__ __volatile__("hlt");
        }
        
-       __asm__ __volatile__("xchg %%bx, %%bx"::"a"(tid));
-       
        for(;;) sleep();
        
        return 42;

UCC git Repository :: git.ucc.asn.au