syscall_proc: document that dofork might do two things
authorAlan Cox <alan@linux.intel.com>
Thu, 21 Jan 2016 11:53:52 +0000 (11:53 +0000)
committerAlan Cox <alan@linux.intel.com>
Thu, 21 Jan 2016 11:53:52 +0000 (11:53 +0000)
On banked platforms it'll probably return twice for now anyway. On some others
the child will return to user space directly on a different kernel stack.

Kernel/syscall_proc.c

index 0acfa56..213d317 100644 (file)
@@ -373,10 +373,18 @@ arg_t _fork(void)
                return -1;
 
        irq = di();
-       // we're going to run our child process next, so mark this process as being ready to run
+       /*
+        * We're going to run our child process next, so mark this process as
+        * being ready to run
+        */
        udata.u_ptab->p_status = P_READY;
-       // kick off the new process (the bifurcation happens inside here, we returns in both 
-       // the child and parent contexts)
+       /*
+        * Kick off the new process (the bifurcation happens inside here, we
+        * *MAY* returns in both the child and parent contexts, however in a
+        * non error case the child may also directly return to userspace
+        * with the return code of 0 and not return from here. Do not assume
+        * you can execute any child code reliably beyond this call
+        */
        r = dofork(new_process);
 #ifdef DEBUG
        kprintf("Dofork %x (n %x)returns %d\n", udata.u_ptab,