aboutsummaryrefslogtreecommitdiff
path: root/src/libthread/exec-unix.c
diff options
context:
space:
mode:
authorrsc <devnull@localhost>2004-03-25 23:03:57 +0000
committerrsc <devnull@localhost>2004-03-25 23:03:57 +0000
commit8ad517944e46710ab832350c0dc3fc4e9239f7e2 (patch)
tree7b99a1833e1b303719c2aac75e3f7e82482b42ab /src/libthread/exec-unix.c
parentcb27443abf3d6af6ab52377c71c843e619928433 (diff)
downloadplan9port-8ad517944e46710ab832350c0dc3fc4e9239f7e2.tar.gz
plan9port-8ad517944e46710ab832350c0dc3fc4e9239f7e2.tar.bz2
plan9port-8ad517944e46710ab832350c0dc3fc4e9239f7e2.zip
Today's changes.
More changes.
Diffstat (limited to 'src/libthread/exec-unix.c')
-rw-r--r--src/libthread/exec-unix.c41
1 files changed, 38 insertions, 3 deletions
diff --git a/src/libthread/exec-unix.c b/src/libthread/exec-unix.c
index bfffa14d..eb31e99e 100644
--- a/src/libthread/exec-unix.c
+++ b/src/libthread/exec-unix.c
@@ -3,8 +3,8 @@
#include "threadimpl.h"
static void efork(int[3], int[2], char*, char**);
-void
-threadexec(Channel *pidc, int fd[3], char *prog, char *args[])
+static void
+_threadexec(Channel *pidc, int fd[3], char *prog, char *args[], int freeargs)
{
int pfd[2];
int n, pid;
@@ -40,6 +40,8 @@ threadexec(Channel *pidc, int fd[3], char *prog, char *args[])
efork(fd, pfd, prog, args);
_exit(0);
default:
+ if(freeargs)
+ free(args);
break;
}
@@ -69,9 +71,42 @@ Bad:
}
void
+threadexec(Channel *pidc, int fd[3], char *prog, char *args[])
+{
+ _threadexec(pidc, fd, prog, args, 0);
+}
+
+/*
+ * The &f+1 trick doesn't work on SunOS, so we might
+ * as well bite the bullet and do this correctly.
+ */
+void
threadexecl(Channel *pidc, int fd[3], char *f, ...)
{
- threadexec(pidc, fd, f, &f+1);
+ char **args, *s;
+ int n;
+ va_list arg;
+
+ va_start(arg, f);
+ for(n=0; va_arg(arg, char*) != 0; n++)
+ ;
+ n++;
+ va_end(arg);
+
+ args = malloc(n*sizeof(args[0]));
+ if(args == nil){
+ if(pidc)
+ sendul(pidc, ~0);
+ return;
+ }
+
+ va_start(arg, f);
+ for(n=0; (s=va_arg(arg, char*)) != 0; n++)
+ args[n] = s;
+ args[n] = 0;
+ va_end(arg);
+
+ _threadexec(pidc, fd, f, args, 1);
}
static void