From 912fba95e74c7631352bc5007249d75e720bbcdf Mon Sep 17 00:00:00 2001 From: rsc Date: Mon, 24 Nov 2003 22:39:06 +0000 Subject: Changes for Mac OS X. Most important is stack sizes in samterm, which were completely bogus. (Libthread used to ignore them but not anymore. Maybe we really should ignore them, but that breaks Venti, which needs *really* big stacks.) --- src/libthread/exec-unix.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'src/libthread/exec-unix.c') 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; } -- cgit v1.2.3