summaryrefslogtreecommitdiff
path: root/sys/src/libthread/main.c
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2021-10-12 00:49:12 +0000
committercinap_lenrek <cinap_lenrek@felloff.net>2021-10-12 00:49:12 +0000
commit07608c768faadfe960872d492d960be3112b7999 (patch)
treedd98f9f231519dcc6a5f2b78164af83a50f851e6 /sys/src/libthread/main.c
parent24bd67f990fde5f25783293f57f651c93ce19125 (diff)
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.
Diffstat (limited to 'sys/src/libthread/main.c')
-rw-r--r--sys/src/libthread/main.c15
1 files changed, 1 insertions, 14 deletions
diff --git a/sys/src/libthread/main.c b/sys/src/libthread/main.c
index a2a2eb0af..48a8acd52 100644
--- a/sys/src/libthread/main.c
+++ b/sys/src/libthread/main.c
@@ -28,8 +28,6 @@ main(int argc, char **argv)
rfork(RFREND);
mainp = &p;
- if(setjmp(_mainjmp))
- _schedinit(p);
//_threaddebuglevel = (DBGSCHED|DBGCHAN|DBGREND)^~0;
_systhreadinit();
@@ -45,6 +43,7 @@ main(int argc, char **argv)
a->argv = argv;
p = _newproc(mainlauncher, a, mainstacksize, "threadmain", 0, 0);
+ setjmp(_mainjmp);
_schedinit(p);
abort(); /* not reached */
}
@@ -117,18 +116,6 @@ void
_schedexit(Proc *p)
{
char ex[ERRMAX];
- Proc **l;
-
- lock(&_threadpq.lock);
- for(l=&_threadpq.head; *l; l=&(*l)->next){
- if(*l == p){
- *l = p->next;
- if(*l == nil)
- _threadpq.tail = l;
- break;
- }
- }
- unlock(&_threadpq.lock);
utfecpy(ex, ex+sizeof ex, p->exitstr);
free(p);