From 07608c768faadfe960872d492d960be3112b7999 Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Tue, 12 Oct 2021 00:49:12 +0000 Subject: libthread: deal with _schedfork() and _schedexec() returning -1 The current behaviour of the kernel to deadlock itself instead of returning an error on fork. This might change in the future, so prepare libthread to handle this case. For _schedfork(), we'r going to just retry forking on every switch, while for _schedexec(), the exec will fail and send ~0 down the pid channel. --- sys/src/libthread/exec.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'sys/src/libthread/exec.c') diff --git a/sys/src/libthread/exec.c b/sys/src/libthread/exec.c index 3bfbda3c6..b3ac6c213 100644 --- a/sys/src/libthread/exec.c +++ b/sys/src/libthread/exec.c @@ -45,8 +45,10 @@ procexec(Channel *pidc, char *prog, char *args[]) close(p->exec.fd[1]); p->exec.fd[1] = n; + while(p->needexec || p->newproc) + _sched(); + /* exec in parallel via the scheduler */ - assert(p->needexec==0); p->exec.prog = prog; p->exec.args = args; p->needexec = 1; @@ -61,6 +63,8 @@ procexec(Channel *pidc, char *prog, char *args[]) } close(p->exec.fd[0]); + if(t->ret == -1) + goto Bad; if(pidc) sendul(pidc, t->ret); -- cgit v1.2.3