ref: 9864d35a9f32b557187a35f76812bffba2d99dc7
parent: d84a6c7a4d9393d2a88d46490c16392a45a1aeaf
author: cinap_lenrek <cinap_lenrek@gmx.de>
date: Tue May 28 19:41:54 EDT 2013
kernel: sysrfork abortion when we fail to fork resources for the child due to resource exhaustion, make the half forked child process call pexit() to free the resources that where allocated and error out.
--- a/sys/src/9/port/sysproc.c
+++ b/sys/src/9/port/sysproc.c
@@ -21,6 +21,12 @@
return 0;
}
+static void
+abortion(void*)
+{+ pexit("fork aborted", 1);+}
+
long
sysrfork(ulong *arg)
{@@ -101,6 +107,14 @@
p->ureg = up->ureg;
p->dbgreg = 0;
+ /* Abort the child process on error */
+ if(waserror()){+ p->kp = 1;
+ kprocchild(p, abortion, 0);
+ ready(p);
+ nexterror();
+ }
+
/* Make a new set of memory segments */
n = flag & RFMEM;
qlock(&p->seglock);
@@ -163,6 +177,8 @@
p->procmode = up->procmode;
if(up->procctl == Proc_tracesyscall)
p->procctl = Proc_tracesyscall;
+
+ poperror(); /* abortion */
/* Craft a return frame which will cause the child to pop out of
* the scheduler in user mode with the return register zero
--
⑨