aboutsummaryrefslogtreecommitdiff
path: root/src/libthread
diff options
context:
space:
mode:
Diffstat (limited to 'src/libthread')
-rw-r--r--src/libthread/channel.c2
-rw-r--r--src/libthread/exec-unix.c16
-rw-r--r--src/libthread/rendez.c4
-rw-r--r--src/libthread/sched.c2
4 files changed, 18 insertions, 6 deletions
diff --git a/src/libthread/channel.c b/src/libthread/channel.c
index 384f23fd..d1ec2985 100644
--- a/src/libthread/channel.c
+++ b/src/libthread/channel.c
@@ -359,7 +359,7 @@ enqueue(Alt *a, Channel **c)
{
int i;
- _threaddebug(DBGCHAN, "Queuing alt %p on channel %p", a, a->c);
+ _threaddebug(DBGCHAN, "Queueing alt %p on channel %p", a, a->c);
a->tag = c;
i = emptyentry(a->c);
a->c->qentry[i] = a;
diff --git a/src/libthread/exec-unix.c b/src/libthread/exec-unix.c
index 5a37e34c..ef50bf19 100644
--- a/src/libthread/exec-unix.c
+++ b/src/libthread/exec-unix.c
@@ -16,6 +16,7 @@ procexec(Channel *pidc, char *prog, char *args[])
if(p->threads.head != t || p->threads.head->nextt != nil){
werrstr("not only thread in proc");
Bad:
+ _threaddebug(DBGEXEC, "procexec bad %r");
if(pidc)
sendul(pidc, ~0);
return;
@@ -35,6 +36,8 @@ procexec(Channel *pidc, char *prog, char *args[])
*/
if(pipe(p->exec.fd) < 0)
goto Bad;
+ if(fcntl(p->exec.fd[0], F_SETFD, 1) < 0)
+ goto Bad;
if(fcntl(p->exec.fd[1], F_SETFD, 1) < 0)
goto Bad;
@@ -57,6 +60,7 @@ procexec(Channel *pidc, char *prog, char *args[])
if(pidc)
sendul(pidc, t->ret);
+ _threaddebug(DBGEXEC, "procexec schedexecwait");
/* wait for exec'ed program, then exit */
_schedexecwait();
}
@@ -105,8 +109,7 @@ efork(void *ve)
Execargs *e;
e = ve;
- _threaddebug(DBGEXEC, "_schedexec %s", e->prog);
- close(e->fd[0]);
+ _threaddebug(DBGEXEC, "_schedexec %s -- calling execv", e->prog);
execv(e->prog, e->args);
_threaddebug(DBGEXEC, "_schedexec failed: %r");
rerrstr(buf, sizeof buf);
@@ -120,5 +123,12 @@ efork(void *ve)
int
_schedexec(Execargs *e)
{
- return ffork(RFFDG|RFPROC|RFMEM, efork, e);
+ int pid;
+
+ pid = fork();
+ if(pid == 0){
+ efork(e);
+ _exit(1);
+ }
+ return pid;
}
diff --git a/src/libthread/rendez.c b/src/libthread/rendez.c
index 62b825b5..70eb0ae8 100644
--- a/src/libthread/rendez.c
+++ b/src/libthread/rendez.c
@@ -52,12 +52,12 @@ _threadnrendez++;
t->rendval = val;
t->rendhash = *l;
*l = t;
- t->nextstate = Rendezvous;
++nrendez;
if(nrendez > _threadhighnrendez)
_threadhighnrendez = nrendez;
- _threaddebug(DBGREND, "Rendezvous for tag %lud", t->rendtag);
+ _threaddebug(DBGREND, "Rendezvous for tag %lud (m=%d)", t->rendtag, t->moribund);
unlock(&_threadrgrp.lock);
+ t->nextstate = Rendezvous;
_sched();
t->inrendez = 0;
_threaddebug(DBGREND, "Woke after rendezvous; val is %lud", t->rendval);
diff --git a/src/libthread/sched.c b/src/libthread/sched.c
index f1fde971..d33587fc 100644
--- a/src/libthread/sched.c
+++ b/src/libthread/sched.c
@@ -41,6 +41,8 @@ _schedinit(void *arg)
if((t=p->thread) != nil){
p->thread = nil;
if(t->moribund){
+ if(t->moribund != 1)
+ fprint(2, "moribund %d\n", t->moribund);
assert(t->moribund == 1);
t->state = Dead;
if(t->prevt)